双引号未在R中转义

aga*_*tha 15 r

我需要在以下示例中转义双引号并且R返回:

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

[1] "the road is 'rocky all \"the\" way'"
Run Code Online (Sandbox Code Playgroud)

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

the road is 'rocky all "the" way' 
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

jub*_*uba 21

你已经实现了它.这只是print()在显示它们时转义引号:

R> xx <- "the road is 'rocky all \"the\" way'"
R> cat(xx)
the road is 'rocky all "the" way'
Run Code Online (Sandbox Code Playgroud)