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

标签 r string quotes double-quotes

考虑以下文本

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



如果我复制并粘贴此文本并尝试将其放入一个变量中,如下所示:
mystring = "Today is the day "Stack Overflow" will miss its year's target"

这是行不通的,因为引号是不平衡的。

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

最佳答案

给警察发短信

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用它。

关于r - 如何复制和粘贴带有不平衡引号的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48464258/

相关文章:

r - 可视化 R 中整数数据的频率

r - ggplot2 未正确保存 geom_raster() 绘图

r - 从坐标生成多边形

c - 按顺序插入字符串数组

Python如何打印不带引号的元组

r - 编写一个函数来过滤和汇总数据到比例表中

java - 从字符串中获取值

html - 如何强制包装没有任何空白的长字符串?

linux - bash 如何处理嵌套引号?

powershell - 包含双引号和单引号的Powershell变量