Hi there,
I am having some trouble getting the str_replace_all and str_squish to work and not sure why.
My actual survey dataset contains 470 columns, where the column names are filled with periods. So, I am trying to:
- remove all the periods and replace them with a space;
- remove any additional spaces; and
- add a question mark at the end of the column names.
This is the code I am working with (using the iris dataset as a test):
data(iris)
indicators <- iris %>%
rename_with(
stringr::str_replace_all("\\.", " ") %>%
stringr::str_squish() %>%
stringr::str_replace_all("$", "?")
)
#> Error in iris %>% rename_with(stringr::str_replace_all("\\.", " ") %>% : could not find function "%>%"
Created on 2022-09-30 with reprex v2.0.2
I saw in this post (str_replace_all problem) that it appears that I am missing a 'replacement value' but I thought the " " in the stringr::str_replace_all("\\.", " ") was the replacement value (i.e. white space)?