R/processing_labels_functions.R
map_labels.RdA new column is created by mapping each input label to some output label and storing.
The mapping argument is of the form c(input_label = "output_label", ...).
These can also be created programmatically with the use of setNames.
map_labels(df, mapping, inner_col, new_col)the same data frame with new column added
df <- data.frame(
some_label_col = c("A", "B", "A")
)
mapping <- c(
A = "Approve",
B = "Reject"
)
map_labels(df, mapping = mapping, inner_col = "some_label_col", new_col = "Decision")
#> # A tibble: 3 × 2
#> some_label_col Decision
#> <chr> <chr>
#> 1 A Approve
#> 2 B Reject
#> 3 A Approve