Often when columns are operated on, their former name will no longer correctly indicate their properties. For example, when binary indicator variables are summed, they become integer count variables instead.
rename_convo(vbls, convo)
vbls | Character vector of variable names to transform |
---|---|
convo |
|
Character vector of column names renamed per convo
specification
This function allows users to specify the rename
property in their convo
to
explain how certain variables ought be renamed when transformed. It plays particularly nicely
with the automatic renaming conventions of dplyr
scoped operators, as shown in the second example.
path <- system.file("", "ex-convo.yml", package = "convo") convo <- read_convo(path) vbl_names <- c("IND_A_AVG", "IND_B_SUM") rename_convo(vbl_names, convo)#> [1] "P_A" "N_B"if (FALSE) { data.frame( IND_A = sample(0:1, 10, replace = TRUE), IND_B = sample(0:1, 10, replace = TRUE) ) %>% summarize_all(list(SUM = sum, AVG = mean)) %>% rename_all(~rename_convo(., convo)) }