rename_dict | R Documentation |
Dictionary Style Renaming
rename_dict(df, old_names, new_names, match_all = TRUE)
df |
A data frame |
old_names |
Character vector of names in |
new_names |
Character vector of new names of the same length as |
match_all |
Do all of |
df
with new names
I like option in pandas to rename using a dictionary so here is an R version.
df = tibble::tibble(
Hammurabi = 1:3,
Cyrus = letters[1:3],
David = LETTERS[1:3]
)
rename_from = c(
'Cyrus',
'Hammurabi',
'Alexander'
)
rename_to = c(
'Cambyses',
'Nebuchadnezzar',
'Ptolemy'
)
rename_dict(
df,
old_names = rename_from,
new_names = rename_to,
match_all = FALSE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.