fmapc: Apply a function column-wise with name access and parallelism

View source: R/fmapc.R

fmapcR Documentation

Apply a function column-wise with name access and parallelism

Description

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.

Usage

fmapc(.df, .f, ncores = NULL, pb = FALSE, ...)

Arguments

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

Value

A list of results obtained by applying '.f' to each column of '.df'.

Examples

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)



functionals documentation built on Aug. 8, 2025, 7:32 p.m.