R/sparse_matrix.R

Defines functions is_sparse

Documented in is_sparse

#' Check if an object is a sparse matrix
#'
#' @param x An object to test
#'
#' @export
#'
#' @importFrom methods is
#'
#' @examples
#' library(Matrix)
#' is_sparse(matrix(1:10)) # FALSE
#' is_sparse(Matrix::rsparsematrix(100, 200, .01)) # TRUE
is_sparse <- function(x) {
  is(x, "sparseMatrix")
}

Try the dynutils package in your browser

Any scripts or data that you put into this service are public.

dynutils documentation built on Oct. 11, 2022, 5:07 p.m.