apply_columns: Apply a function to specific columns

View source: R/surveys.R

apply_columnsR Documentation

Apply a function to specific columns

Description

Apply a function to a specified set of columns in a data frame

Usage

apply_columns(df, fun, cols, ...)

Arguments

df

The data.frame to apply to

fun

The function to apply. The first parameter should be the column of data

cols

The set of columns to apply to

...

Additional parameters to pass into fun

Value

A new copy of the data frame with the modified columns

Examples

df <- data.frame(one=c("1.0", "2.0"), two=c("3.0", "4.0"))
df <- apply_columns(df, as.numeric, c("one", "two"))

rwash/surveys documentation built on Sept. 18, 2023, 11:31 p.m.