19

我需要在以下示例中转义双引号,然后 R 返回:

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

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

最后的字符串应该包含单引号和双引号

the road is 'rocky all "the" way' 

我怎样才能做到这一点?

4

1 回答 1

29

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

R> xx <- "the road is 'rocky all \"the\" way'"
R> cat(xx)
the road is 'rocky all "the" way'
于 2013-02-19T14:42:53.497 回答