Rename every column of a dataframe with its label
Arguments
- df
a data.frame
- except
<
tidy-select
> columns that should not be renamed.
Examples
rename_with_labels(mtcars2[,1:5], except=5) %>% names()
#> [1] "Model" "Miles/(US) gallon" "Number of cylinders"
#> [4] "Displacement (cu.in.)" "hp"
rename_with_labels(iris2, except=Sepal.Length) %>% names()
#> [1] "Sepal.Length" "Width of Sepal" "Length of Petal" "Width of Petal"
#> [5] "Specie"
rename_with_labels(iris2, except=starts_with("Pet")) %>% names()
#> [1] "Length of Sepal" "Width of Sepal" "Petal.Length" "Petal.Width"
#> [5] "Specie"