CBapply: This function is a wrapper for sapply with simplify=FALSE and...

Description Usage Arguments Examples

View source: R/z_deprecated.R

Description

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).

Usage

1
2
CBapply(X, FUN, output = "data.frame", fill = FALSE, num.cores = 1,
  ...)

Arguments

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

Examples

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)))

cole-brokamp/CB documentation built on May 13, 2019, 8:49 p.m.