R/mlapply.R

Defines functions mlapply

Documented in mlapply

mlapply <- function(lol,FUN,...){
  llol <- sapply(lol, length)
  nrows <- llol[1]
  if (any(llol != nrows)) stop("lists not of same length")
  
  arglists <- lapply(as.list(1:length(lol[[1]])),
                     function(i) lapply(lol, `[[`, i))
  names(arglists) <- names(lol[[1]])
  lapply(arglists, function(x)do.call(FUN,c(x,...)))
}

Try the ENmisc package in your browser

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

ENmisc documentation built on May 2, 2019, 5:52 a.m.