transform_columns: Apply transformations to an arbitrary number of columns.

View source: R/utility-functions.R

transform_columnsR Documentation

Apply transformations to an arbitrary number of columns.

Description

This function takes a named list of purr-style lambdas where names are the names of the columns in the data frame that must be transformed. NOTE: the columns are overridden, not appended.

Usage

transform_columns(df, transf_list)

Arguments

df

The data frame on which transformations should be operated

transf_list

A named list of purrr-style lambdas, where names are column names the function should be applied to.

Details

Lambdas provided in input must be transformations, aka functions that take in input a vector and return a vector of the same length as the input.

If the input transformation list contains column names that are not present in the input data frame, they are simply ignored.

Value

A data frame with transformed columns

See Also

Other Utilities: as_sparse_matrix(), comparison_matrix(), enable_progress_bars(), export_ISA_settings(), generate_Vispa2_launch_AF(), generate_blank_association_file(), generate_default_folder_structure(), import_ISA_settings(), separate_quant_matrices()

Examples

df <- tibble::tribble(
    ~A, ~B, ~C, ~D,
    1, 2, "a", "aa",
    3, 4, "b", "bb",
    5, 6, "c", "cc"
)
lambdas <- list(A = ~ .x + 1, B = ~ .x + 2, C = ~ stringr::str_to_upper(.x))
transform_columns(df, lambdas)

calabrialab/ISAnalytics documentation built on Dec. 10, 2024, 10:50 p.m.