fmapc | R Documentation |
Applies a function '.f' to each column of a data frame '.df'. Each call receives both the column vector and its name, enabling name-aware column processing. Supports parallel execution and progress display.
fmapc(.df, .f, ncores = NULL, pb = FALSE, ...)
.df |
A data frame whose columns will be iterated over. |
.f |
A function that takes two arguments: the column vector and its name. |
ncores |
Integer. Number of cores to use for parallel processing. Default is 'NULL' (sequential). |
pb |
Logical. Whether to display a progress bar. Default is 'FALSE'. |
... |
Additional arguments passed to '.f'. |
A list of results obtained by applying '.f' to each column of '.df'.
df <- data.frame(a = 1:3, b = 4:6)
# Apply a function that returns column mean and name
fmapc(df, function(x, name) list(mean = mean(x), var = var(x), name = name))
# With progress and parallel execution
fmapc(df, function(x, name) mean(x), ncores = 2, pb = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.