Type: | Package |
Title: | I/O Operations with Sparse Matrices |
Version: | 1.0.1 |
Date: | 2020-01-13 |
Maintainer: | Dmitriy Selivanov <selivanov.dmitriy@gmail.com> |
Encoding: | UTF-8 |
Description: | 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/. |
License: | GPL-2 | GPL-3 | file LICENSE [expanded from: GPL (≥ 2) | file LICENSE] |
Depends: | R (≥ 3.1.0), methods |
Imports: | Rcpp (≥ 0.12.0), Matrix (≥ 1.1) |
LinkingTo: | Rcpp |
Suggests: | testthat |
URL: | https://github.com/dselivanov/sparsio |
BugReports: | https://github.com/dselivanov/sparsio/issues |
RoxygenNote: | 6.1.1 |
NeedsCompilation: | yes |
Packaged: | 2020-01-13 07:06:19 UTC; dselivanov |
Author: | Dmitriy Selivanov [aut, cre], Felix Riedel [aut] |
Repository: | CRAN |
Date/Publication: | 2020-01-13 08:20:03 UTC |
Fast svmlight reader and writer
Description
Reads and writes svmlight files. Notice that current implementation can't handle comments in svmlight files during reading.
Usage
read_svmlight(file, type = c("CsparseMatrix", "RsparseMatrix",
"TsparseMatrix"), zero_based = TRUE, ncol = NULL)
write_svmlight(x, y = rep(0, nrow(x)), file, zero_based = TRUE)
Arguments
file |
string, path to svmlight file |
type |
target class for sparse matrix. |
zero_based |
|
ncol |
number of columns in target matrix. |
x |
input sparse matrix. Should inherit from |
y |
target values. Labels must be an integer or numeric of the same length as number of rows in |
Examples
library(Matrix)
library(sparsio)
i = 1:8
j = 1:8
v = 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)