Rename data frame columns using external crosswalk file.
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 )
.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 ( |
Data frame or tbl_df with new column names and labels.
renamefrom_
: Standard evaluation version of
renamefrom
(raw
, clean
, and
label
must be strings when using this version)
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)