I would like to change multiple strings in a variable with multiple replacements. Preferably with for example stringr
because qdap
has a lot of dependencies and I can't get it to work. I'm inclined to think something like the following should work, but it doesn't. Also not when escaping the string brackets or dots with \\
.
library(stringr)
data <- c("Partij van de Arbeid (P.v.d.A.)",
"VVD",
"GROENLINKS",
"Democraten 66 (D66)")
str_replace_all(data, c("Partij van de Arbeid (P.v.d.A.)",
"GROENLINKS",
"Democraten 66 (D66)"),
c("PVDA",
"GL",
"D66"))
Wanted output:
> data
[1] "PVDA" "VVD" "GL" "D66"