简体   繁体   English

用 gsub R 替换“\\”字符

[英]replace "\" character with gsub R

Does anybody knows how can i replace "\\" in r?有人知道如何替换 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: \\n是换行符,如果你想用空格替换它,你可以使用以下命令:

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

Note, that the output would be:请注意,输出将是:

1120190
economic
[1] "1120190 economic"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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