如何在R中转义反斜杠? [英] How to escape a backslash in R?

查看:94
本文介绍了如何在R中转义反斜杠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 R 中工作并且在转义反斜杠时遇到了麻烦.我正在使用库 stringr.

I'm working in R and having troubles escaping the backslash. I am using the library stringr.

install.packages("stringr", repos='http://cran.us.r-project.org')
library("stringr")

我想做 str = str_replace_all(str, "\", "")

所以我尝试了 str = str_replace_all(str, "\\", "") 但它不起作用.

So I tried str = str_replace_all(str, "\\", "") but it won't work.

我该怎么办?

推荐答案

我找到了一个有效的解决方案

I found a solution that works

str = gsub("([\\])","", str)

这篇关于如何在R中转义反斜杠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆