Can not run the code of str_remove

Below codes I copied from an example in this community:

fruits <- c("one apple", "two pears", "three bananas")
str_remove(fruits, "[aeiou]")
str_remove_all(fruits, "[aeiou]")

But when I run it, there was a warning for str_remove(fruits, "[aeiou]") such:
Error in str_replace_all(., pattern = remove_words %>% paste0("(", ., :
could not find function "str_replace_all"
and str_remove_all(fruits, "[aeiou]") such:
Error during wrapup: could not find function "str_remove_all"

Can anyone please explain why the codes were not working?

Hi there, @ferkingshelby! Did you load the stringr package before running this example? It comes with the tidyverse but isn't attached when you load it, so you'll need to separately run library(stringr) in order to access functions like str_remove(). That might be the problem you're having!


Thank you so much @rensa. Now it works perfectly! Sorry I am newbie in R so not quite familiar with command. :slight_smile:

1 Like

That's okay! Glad we could help :smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.