R/arraytolist.R

#' arraytolist
#'
#' converts an array in a list storing each element of the third dimension of the array (specimen) as element of the list 
#' @param array a kx3xn array with landmark coordinates
#' @return a list containing the landmark configurations stored as separated elements 
#' @author Antonio Profico, Costantino Buzi, Marina Melchionna, Paolo Piras, Pasquale Raia, Alessio Veneziano
#' @export

arraytolist<-function (array) 
{
  thelist <- NULL
  for (i in 1:dim(array)[3]) {
    eli <- array[, , i]
    thelist <- c(thelist, list(eli))
  }
  if (is.null(dimnames(array)[[3]]) == F) {
    names(thelist) <- dimnames(array)[[3]]
  }
  return(thelist)
}

Try the Arothron package in your browser

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

Arothron documentation built on Feb. 16, 2023, 5:17 p.m.