renamefrom {crosswalkr} | R Documentation |
Rename data frame columns using external crosswalk file.
Description
Rename data frame columns using external crosswalk file.
Usage
renamefrom(
.data,
cw_file,
raw,
clean,
label = NULL,
delimiter = NULL,
sheet = NULL,
drop_extra = TRUE,
case_ignore = TRUE,
keep_label = FALSE,
name_label = FALSE
)
renamefrom_(
.data,
cw_file,
raw,
clean,
label = NULL,
delimiter = NULL,
sheet = NULL,
drop_extra = TRUE,
case_ignore = TRUE,
keep_label = FALSE,
name_label = FALSE
)
Arguments
.data |
Data frame or tbl_df |
cw_file |
Either data frame object or string with path to
external crosswalk file, which has columns representing
|
raw |
Name of column in |
clean |
Name of column in |
label |
Name of column in |
delimiter |
String delimiter used to parse
|
sheet |
Specify sheet if |
drop_extra |
Drop extra columns in current data frame if they
are not matched in |
case_ignore |
Ignore case when matching current ( |
keep_label |
Keep current label, if any, on data frame columns
that aren't matched in |
name_label |
Use old ( |
Value
Data frame or tbl_df with new column names and labels.
Functions
-
renamefrom_
: Standard evaluation version ofrenamefrom
(raw
,clean
, andlabel
must be strings when using this version)
Examples
df <- data.frame(state = c('Kentucky','Tennessee','Virginia'),
fips = c(21,47,51),
region = c('South','South','South'))
cw <- data.frame(old_name = c('state','fips'),
new_name = c('stname','stfips'),
label = c('Full state name', 'FIPS code'))
df1 <- renamefrom(df, cw, old_name, new_name, label)
df2 <- renamefrom(df, cw, old_name, new_name, name_label = TRUE)
df3 <- renamefrom(df, cw, old_name, new_name, drop_extra = FALSE)