| renvar | R Documentation |
Renames variables in an explicit data frame or the active R4VN data frame.
renvar(..., data = NULL)
... |
In active mode: |
data |
Optional explicit data frame object. |
The edited data frame invisibly.
d <- data.frame(sex = 1:2, age_kt = 3:4)
usedf(d, quiet = TRUE)
renvar(sex, gender)
renvar("*_kt", "*")
# Extended usage examples
d <- data.frame(sex = 1:2, age = 3:4, score_pre = 5:6, bmi_pre = 7:8)
# Rename one variable
d1 <- d; renvar(d1, sex, gender)
# Rename parallel groups
d2 <- d; renvar(d2, vars(sex, age), vars(gender, age_year))
# Space-separated names are also accepted
d3 <- d; renvar(d3, "sex age", "gender age_year")
# Wildcard: remove or replace a common suffix
d4 <- d; renvar(d4, "*_pre", "*")
d5 <- d; renvar(d5, "*_pre", "baseline_*")
# Active-data syntax
usedf(d, quiet = TRUE); renvar(sex, gender)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.