R/applyFunToListOfObj.R

Defines functions applyFunToListOfObj

Documented in applyFunToListOfObj

#' Apply function to a list of objects
#' 
#' @param lst A lst of objects/variables
#' @param FUN A function to be executed upon the objects/variables
#' @return A list where each element corresponds to the outputs from the function, and names after the named elements of supplied list
#' @export

applyFunToListOfObj <- function(lst, FUN, ...){
  outLstOfVar <- list()
  for(i in 1:length(lst)){
    print(paste("Working on ",names(lst)[i],sep=""))
    Obj_i <-  lst[[i]]
    Obj_i_new <- FUN(Obj_i, ...)
    outLstOfVar <- lappend(outLstOfVar,Obj_i_new)
  }
  names(outLstOfVar) <- names(lst)
  return(outLstOfVar)
}
msxakk89/dat documentation built on Aug. 3, 2020, 6:39 p.m.