View source: R/utility-functions.R
transform_columns | R Documentation |
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.
transform_columns(df, transf_list)
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. |
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.
A data frame with transformed columns
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()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.