Apply a function over selected columns
capply.RdApply a function over selected columns.
Details
Has some coercion limitations. e.g. you cannot convert to factor (it will result in character columns).
Examples
#----------------------------------------------------------------------------
# capply() examples
#----------------------------------------------------------------------------
library(bkmisc)
df <- data.frame(factor = factor(c("a", "b")), numeric = c(1, 2))
# convert factor column to character
capply(df, sapply(df, is.factor), as.character)
#> factor numeric
#> 1 a 1
#> 2 b 2