| rename_se | R Documentation |
rename columns (much different syntax than rename_at).
All left hand sides are new column names and all right hand sides are old column names (
this allows swaps).
rename_se(.data, mapping, splitTerms = TRUE, env = parent.frame())
.data |
data.frame |
mapping |
named character vector of columns to rename (new names on the left, original names on the right; this may seem reversed but it matches dplyr::rename()). |
splitTerms |
logical, if TRUE into separate renames (if FALSE instead, pass all at once to dplyr). |
env |
environment to work in. |
Note: this method as the default setting splitTerms = TRUE, which is
safer (avoiding certain known dplyr/dblyr issues)
(please see the side-notes of https://winvector.github.io/FluidData/partition_mutate.html for some references).
.data with renamed columns
rename, rename_at, :=
datasets::mtcars %.>%
rename_se(., c("cylinders" := "cyl", "gears" := "gear")) %.>%
head(.)
# # same as:
# datasets::mtcars %>%
# rename(cylinders = cyl, gears = gear) %>%
# head()
# rename_se allows column swaps
data.frame(a = 1, b = 2) %.>%
rename_se(., c('a', 'b') := c('b', 'a'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.