I have a list of functions I want to apply to a string consecutively, changing the string. For example, a list of regular expressions I want to remove from a string, e.g.
to_remove = c('a','b')
original = 'abcabd'
In this case, I could use a simple regular expression, e.g. 'a|b'.
library(stringr)
str_remove( original, paste0( to_remove, collapse='|'))
The actual situation is more complex than this, and the regular expression gets a little hairy. Also, I am curious how to do this in a proper R way.
Another way to phrase the question is, "How can I implement the following for loop using a vector approach?"
for( rem in to_remove) {
original = str_remove( original, rem )
}
'