如何复制和粘贴带有不平衡引号的字符串?

时间:2018-01-26 15:19:00

标签: r string quotes double-quotes

考虑以下文字

  

今天是#34; Stack Overflow"将错过今年的目标

如果我复制并粘贴此文本,我会尝试将其放入变量中,如下所示:

mystring = "Today is the day "Stack Overflow" will miss its year's target"

这不起作用,因为引号是不平衡的。

有简单的解决方案吗?如何将此文本复制并粘贴到我的R脚本?

1 个答案:

答案 0 :(得分:2)

发送给警察的文字 y

Today is the day "Stack Overflow" will miss its year's target.
Yesterday is the day "Stack Overflow" will miss its year's target's sum.

阅读R

x = readLines("clipboard")
#Warning message:
#In readLines("clipboard") : incomplete final line found on 'clipboard'

转换为data.frame

data.frame(x)                                                                             
#                                                                        x
#1           Today is the day "Stack Overflow" will miss its year's target.
#2 Yesterday is the day "Stack Overflow" will miss its year's target's sum.

您也可以将复制的文字粘贴到文件中,而不是使用"clipboard",而是使用readLines