在R中没有转义的双引号

时间:2021-01-06 20:05:47

I need the to escape the double quotes in the following example and R returns :

我需要将下面例子中的双引号转义,R返回:

xx<-"the road is 'rocky all \"the\" way'"
xx

[1] "the road is 'rocky all \"the\" way'"

The final string should contain both the single and the double quotes

最后一个字符串应该包含单引号和双引号。

the road is 'rocky all "the" way' 

How can I achieve this?

我如何做到这一点?

1 个解决方案

#1


18  

You already achieved it. It's just that print() escapes the quotes when displaying them :

你已经实现了它。只是在显示时,print()会转义:

R> xx <- "the road is 'rocky all \"the\" way'"
R> cat(xx)
the road is 'rocky all "the" way'

#1


18  

You already achieved it. It's just that print() escapes the quotes when displaying them :

你已经实现了它。只是在显示时,print()会转义:

R> xx <- "the road is 'rocky all \"the\" way'"
R> cat(xx)
the road is 'rocky all "the" way'

相关文章