R/listTomatrix.R

Defines functions listTomatrix

# This is a function to transform a list of vectors of the same length into a matrix

listTomatrix <- function(l){
  n <- length(l)
  s <- length(l[[1]])
  m <- matrix(nrow = n, ncol = s)
  for (i in 1 : n) {
    m[i,] <- l[[i]]
  }
  m
}

Try the mlmts package in your browser

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

mlmts documentation built on Sept. 11, 2024, 6:41 p.m.