rename_convo: Rename computed columns based on controlled vocabulary

Description Usage Arguments Details Value Examples

View source: R/rename.R

Description

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.

Usage

1
rename_convo(vbls, convo)

Arguments

vbls

Character vector of variable names to transform

convo

convo object with at least one vocabulary item with rename property

Details

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.

Value

Character vector of column names renamed per convo specification

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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)


## Not run: 
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))

## End(Not run)

emilyriederer/convo documentation built on Oct. 5, 2021, 4:08 p.m.