s2d {GMKMcharlie} | R Documentation |
Sparse to dense conversion
Description
Convert data from sparse representation (list of data frames) to dese representation (matrix).
Usage
s2d(
X,
d,
zero = 0,
verbose = TRUE
)
Arguments
X |
A list of size |
d |
An integer. The dimensionality of |
zero |
A numeric value. In the result matrix, entries not registered in |
verbose |
A boolean value. |
Value
A d x N
numeric matrix.
Examples
N = 2000L
d = 3000L
X = matrix(rnorm(N * d) + 2, nrow = d)
# Fill many zeros in X:
X = apply(X, 2, function(x) {
x[sort(sample(d, d * runif(1, 0.95, 0.99)))] = 0; x})
# Get the sparse version of X.
sparseX = GMKMcharlie::d2s(X)
# Convert it back to dense.
X2 = GMKMcharlie::s2d(sparseX, d)
range(X - X2)
[Package GMKMcharlie version 1.1.5 Index]