R/mat2list.R

Defines functions mat2list

Documented in mat2list

#' Create a list of each column of a matrix
#'
#' @param X 
#'
#' @return list of each column of X
#' @export
#'
#' @examples
mat2list <- function(X){
  
  # Turns the p columns of a matrix into a p length list,
  # with each column becoming an element of the list
  
  out <- vector(mode = 'list', length = ncol(X))
  for(i in 1:ncol(X)){
    out[[i]] <- X[ , i]
  }
  out
  
}
dougmcneall/imptools documentation built on Nov. 13, 2021, 7:12 p.m.