I was looking at this question:
R: gsub, pattern = vector and replacement = vector
I am trying a simple example and I can't get it to work.
testList <- c("apple", "orange", "banana1", "apple4", "orange 8", "banana 10")
repl <- c("apple", "orange", "banana")
pat <- paste0("^", repl, "[[:space:]]*[[:digit:]]*$")
result <- mgsub(pat, repl, testList)
Shouldn't this output:
"apple", "orange", "banana", "apple", "orange", "banana"