R/build_sparse_matrix.R

Defines functions build_sparse_matrix

build_sparse_matrix <- function(i, p, x = NULL, dims) {

  if (is.null(x)) {
    # Boolean (pattern) matrix — no x slot
    res <- Matrix::sparseMatrix(
      i = i, p = p, index1 = FALSE,
      dims = dims
    )
  } else {
    res <- Matrix::sparseMatrix(
      i = i, p = p, x = x, index1 = FALSE,
      dims = dims
    )
  }

  return(res)

}

Try the fcaR package in your browser

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

fcaR documentation built on July 27, 2026, 5:06 p.m.