Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

read.matrix.csr

Read/Write Sparse Data


Description

reads and writes a file in sparse data format.

Usage

read.matrix.csr(file, fac = TRUE, ncol = NULL)
write.matrix.csr(x, file = "out.dat", y = NULL, fac = TRUE)

Arguments

x

An object of class matrix.csr

y

A vector (either numeric or a factor)

file

The filename.

fac

If TRUE, the y-values (if any) are interpreted as factor levels.

ncol

Number of columns, detected automatically. Can be used to add empty columns (possibly not stored in the sparse format).

Value

If the data file includes no y variable, read.matrix.csr returns an object of class matrix.csr, else a list with components:

x

object of class matrix.csr

y

vector of numeric values or factor levels, depending on fac.

Author(s)

See Also

Examples

## Not run: 
library(methods)
if (require(SparseM)) {
    data(iris)
    x <- as.matrix(iris[,1:4])
    y <- iris[,5]
    xs <- as.matrix.csr(x)
    write.matrix.csr(xs, y = y, file = "iris.dat")
    xs2 <- read.matrix.csr("iris.dat")$x
    if (!all(as.matrix(xs) == as.matrix(xs2)))
        stop("Error: objects are not equal!")
}

## End(Not run)

e1071

Misc Functions of the Department of Statistics, Probability Theory Group (Formerly: E1071), TU Wien

v1.7-11
GPL-2 | GPL-3
Authors
David Meyer [aut, cre], Evgenia Dimitriadou [aut, cph], Kurt Hornik [aut], Andreas Weingessel [aut], Friedrich Leisch [aut], Chih-Chung Chang [ctb, cph] (libsvm C++-code), Chih-Chen Lin [ctb, cph] (libsvm C++-code)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.