Hi- I want to drop the parts of a column name that is starts with "Household.Level.form." Using the below creates a value and does not just rename the columns...
df_child_level <- df_child_level %>%
str_replace_all("Household.Level.form.","")
Hi- I want to drop the parts of a column name that is starts with "Household.Level.form." Using the below creates a value and does not just rename the columns...
df_child_level <- df_child_level %>%
str_replace_all("Household.Level.form.","")
Assuming that all variables you are looking to rename starts with "Household.Level.form.", you can use rename_with()
and gsub()
:
df_child_level <- tibble("Household.Level.form.One" = runif(1:10),
"Household.Level.form.Two" = runif(1:10))
df_child_level %>%
rename_with(~ gsub("Household.Level.form.", "", .x, fixed = TRUE))
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.