Obiettivo: trasformare x in y; dove x ha un numero arbitrario di spazi, rs e ns.
x <- "some text, rn rn)more text"
y <- "some text)more text"
Ho fatto alcuni tentativi usando str_replace_all ():
str_replace_all(x, "[,][ rn][)]", "")
str_replace_all(x, ",[ rn])", "")
risposte:
2 per risposta № 1gsub
farà questo lavoro per te.
gsub(",\s*\n\s*\)", ")", s)
o
gsub(",\s*[\r\n]+\s*\)", ")", s)
Esempio:
> x <- "some text, rn rn)more text"
> gsub(",\s*\n\s*\)", ")", x)
[1] "some text)more text"