# d2s

From GMKMcharlie v1.0.3
by Charlie Wusuo Liu

##### Dense to sparse conversion

Convert data from dense representation (matrix) to sparse representation (list of data frames).

##### Usage

```
d2s(
X,
zero = 0,
threshold = 1e-16,
verbose= TRUE
)
```

##### Arguments

- X
A

`d x N`

numeric matrix where`N`

is the number of data points --- each column is an observation, and`d`

is the dimensionality. Column-observation representation promotes cache locality.- zero
A numeric value. Elements in

`X`

satisfying`abs(X[i]`

`-`

`zero)`

`<= threshold`

are treated as zeros. Default 0.- threshold
A numeric value, explained above.

- verbose
A boolean value.

`TRUE`

prints progress.

##### Value

A list of size `N`

. `Value[[i]]`

is a 2-column data frame. The 1st column is a sorted integer vector of the indexes of nonzero dimensions. Values in these dimensions are stored in the 2nd column as a numeric vector.

##### Examples

```
# NOT RUN {
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)
str(sparseX[1:5])
# }
```

*Documentation reproduced from package GMKMcharlie, version 1.0.3, License: GPL-3*

### Community examples

Looks like there are no examples yet.