Description Usage Arguments Examples
This function is a wrapper for sapply with simplify=FALSE and USE.NAMES=TRUE. It then rbinds via do.call to return data.frame. In order for the names to work properly, a function that returns a data.frame must be used (see example).
1 2 |
X |
List of objects to apply over |
FUN |
Function to apply |
output |
Output type. Defaults to 'data.frame', but can also be set to 'list' to suppress rbinding of the list. |
fill |
(defaults to FALSE) use plry::rbind.fill to fill in missing columns |
num.cores |
Defaults to 1 and the base 'sapply' is used. If set to greater than one, then it is the number of cores used in parallel::mclapply(). |
... |
Additional arguments to the function |
1 2 3 4 5 | X <- as.data.frame(matrix(runif(100),ncol=10))
names(X) <- LETTERS[1:10]
# CBapply(X,mean) # <- will return error
# function must return a data.frame with named columns for column names to work
CBapply(X,function(x) data.frame('mean'=mean(x)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.