我需要在以下示例中转义双引号并且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'
我怎样才能做到这一点?
答案 0 :(得分:20)
你已经实现了它。只是print()
在显示时忽略了引号:
R> xx <- "the road is 'rocky all \"the\" way'"
R> cat(xx)
the road is 'rocky all "the" way'