简体   繁体   中英

replace "\" character with gsub R

Does anybody knows how can i replace "\\" in r?

Other answers have posted something like:

l <- "1120190\neconomic"
gsub("\\", "", l, fixed=TRUE)

But didn't work in my case.

The \\n is a symbol for newline and if you want to replace it with space you can use the following:

l <- "1120190\neconomic"
cat(l)
gsub("\n", " ", l, fixed=TRUE)

Note, that the output would be:

1120190
economic
[1] "1120190 economic"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM