Imagine you're working with a large dataset in R and you need to remove a common prefix from a set of strings. How would you do it?

  • Use the str_remove() function from stringr package
  • Use the gsub() function
  • Use the sub() function
  • All of the above
All the options mentioned are ways to remove a common prefix from a set of strings. str_remove() from stringr, gsub(), and sub() from base R could all be used to achieve this, given the correct pattern and replacement arguments.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *