#' Apply function to a character vector of object names
#'
#' @param characterVecOfObj A character vector of object/variable names that are currently in working R memory
#' @param FUN A function to be executed upon the objects/variables (not the character strings!)
#' @return A list where each element corresponds to the outputs from the function, and names after the supplied character vector.
#' @export
applyFunToVectorOfObjects <- function(characterVecOfObj, FUN, ...){
outLstOfVar <- list()
for(i in 1:length(characterVecOfObj)){
print(paste("Working on ",characterVecOfObj[i],sep=""))
Obj_i <- get(characterVecOfObj[i])
Obj_i_new <- FUN(Obj_i, ...)
outLstOfVar <- lappend(outLstOfVar,assign(x = characterVecOfObj[i],value = Obj_i_new))
}
names(outLstOfVar) <- paste(characterVecOfObj,sep="")
return(outLstOfVar)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.