powered by
Computes data sparsity (proportion of zeros).
sparsity(x, ...)# S4 method for matrix sparsity(x, count = FALSE)# S4 method for data.frame sparsity(x, count = FALSE)
# S4 method for matrix sparsity(x, count = FALSE)
# S4 method for data.frame sparsity(x, count = FALSE)
A length-one numeric vector.
numeric
An R object (should be a matrix or a data.frame).
matrix
data.frame
Currently not used.
A logical scalar: should a count be returned instead of a proportion?
logical
N. Frerebeau
If x is a data.frame, sparsity is computed on numeric variables only.
x
Other data summaries: describe()
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)
Run the code above in your browser using DataLab