powered by
These are methods for the dplyr generics rename() and rename_with(). They are both translated to data.table::setnames().
rename()
rename_with()
data.table::setnames()
# S3 method for dtplyr_step rename(.data, ...)# S3 method for dtplyr_step rename_with(.data, .fn, .cols = everything(), ...)
# S3 method for dtplyr_step rename_with(.data, .fn, .cols = everything(), ...)
A lazy_dt()
lazy_dt()
For rename(): <tidy-select> Use new_name = old_name to rename selected variables.
tidy-select
new_name = old_name
For rename_with(): additional arguments passed onto .fn.
.fn
A function used to transform the selected .cols. Should return a character vector the same length as the input.
.cols
<tidy-select> Columns to rename; defaults to all columns.
library(dplyr, warn.conflicts = FALSE) dt <- lazy_dt(data.frame(x = 1, y = 2, z = 3)) dt %>% rename(new_x = x, new_y = y) dt %>% rename_with(toupper)
Run the code above in your browser using DataLab