R/add_col.R

Defines functions add_col

add_col <- function(M, sparse_v) {

  sparse_v <- methods::as(sparse_v, "dgCMatrix")

  newM <- M

  newM@i <- c(newM@i, as.integer(sparse_v@i))
  newM@p <- c(newM@p, max(newM@p) + length(sparse_v@i))
  newM@Dim[2] <- as.integer(newM@Dim[2] + 1)

  if (!methods::is(M, "ngCMatrix")) {

    newM@x <- c(newM@x, sparse_v@x)

  }

  return(newM)

}

Try the fcaR package in your browser

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

fcaR documentation built on June 29, 2021, 1:06 a.m.