Fast 'SVMlight' reader and writer. 'SVMlight' is most commonly used format for storing sparse matrices (possibly with some target variable) on disk. For additional information about 'SVMlight' format see < http://svmlight.joachims.org/>.
sparsio is an R package for I/O operations with sparse matrices. At the moment it provides fast svmlight
reader and writer.
read_svmlight()
write_svmlight()
The only dependency is Rcpp
Package is not on CRAN yet, so you can install it with devtools
:
devtools::install_github("dselivanov/sparsio")
library(Matrix)library(sparsio)i = 1:8j = 1:8v = rep(2, 8)x = sparseMatrix(i, j, x = v)y = sample(c(0, 1), nrow(x), replace = TRUE)f = tempfile(fileext = ".svmlight")write_svmlight(x, y, f)x2 = read_svmlight(f, type = "CsparseMatrix")identical(x2$x, x)identical(x2$y, y)