rename_se: rename standard interface.

Description Usage Arguments Details Value See Also Examples

View source: R/rename_se.R

Description

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).

Usage

1
rename_se(.data, mapping, splitTerms = TRUE, env = parent.frame())

Arguments

.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.

Details

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).

Value

.data with renamed columns

See Also

rename, rename_at, :=

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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'))

seplyr documentation built on June 12, 2021, 5:07 p.m.