sparsity | R Documentation |
Computes data sparsity (proportion of zeros).
sparsity(x, ...)
## S4 method for signature 'matrix'
sparsity(x, count = FALSE)
## S4 method for signature 'data.frame'
sparsity(x, count = FALSE)
x |
An R object (should be a |
... |
Currently not used. |
count |
A |
If x
is a data.frame
, sparsity is computed on numeric
variables only.
A length-one numeric
vector.
N. Frerebeau
Other data summaries:
describe()
## Create a data matrix
X <- matrix(sample(0:9, 15, TRUE), nrow = 3, ncol = 5)
## Add NA
k <- sample(1:15, 3, FALSE)
X[k] <- NA
## Sparsity
sparsity(X)
## Quick description
describe(X)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.