【问题标题】:Adding ' " ' quote inside a paste command in R在 R 中的粘贴命令中添加 '"' 引号
【发布时间】:2013-01-08 07:40:41
【问题描述】:

我试图在 R 中的粘贴命令中包含 "(双引号)

paste("perl -ane 'system("cat /auto/Sample_output/tmp.$F[0].vcf >> Sample_90061.vcf");'",sep="")

它说

Error: unexpected symbol in "paste("perl -ane 'system("cat"

我尝试单独创建引用的部分,然后将其粘贴

complicated = paste('"cat /auto/Sample_output/tmp.$F[0].vcf >> Sample_90061.vcf"',sep="")

但它显示为

> complicated
[1] "\"cat /auto/Sample_output/tmp.$F[0].vcf >> Sample_90061.vcf\""

有人可以帮我解决这个问题吗?

【问题讨论】:

  • 放入“in”。你用 \" 例如:"男孩说,\"Hello World!\""
  • shQuotesQuotedQuote 也可能是需要研究的函数。

标签: r


【解决方案1】:

使用反斜杠 \ 转义 "。所以你将拥有:

paste("perl -ane 'system(\"cat /auto/Sample_output/tmp.$F[0].vcf >> Sample_90061.vcf\");'",sep="")

【讨论】:

  • 是的。如果字符串用单引号括起来,有时可以包含",但这里没有尝试,因为这个答案“更正确”。
猜你喜欢
  • 2022-12-07
  • 2019-08-16
  • 2014-02-17
  • 1970-01-01
  • 2018-03-30
  • 1970-01-01
  • 1970-01-01
  • 2014-05-28
  • 2017-10-13
相关资源
最近更新 更多