First, let's look at the simple usage of an R function called lapply() (refer to the following code):
> lapply(1:3,function(x) c(sin(x),x^2)) [[1]] [1] 0.841471 1.000000 [[2]] [1] 0.9092974 4.0000000 [[3]] [1] 0.14112 9.00000
The meaning is clear: we have an input size of 1, 2, and 3 and we assign them to three functions. The following example is a slightly more complex one:
myFunctions<-c(sin(x),x^2+2,4*x^2-x^3-2) inputValue<-1:10 output<-lapply(inputValue,function(x) myFunctions)
The first couple of lines are shown here:
The following example is borrowed from Gordon (2015):
library(parallel) n_cores <- detectCores() ...