1

I'm trying to have " (double quote) inside a pasted command in R

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

it says

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

I tried to create the quoted part alone and then paste it by

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

but it shows as

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

Can somebody help me to solve this issue?

Adam Stelmaszczyk
  • 19,665
  • 4
  • 70
  • 110
Jana
  • 1,523
  • 3
  • 14
  • 17

1 Answers1

4

Escape " with backslash \. So you will have:

paste("perl -ane 'system(\"cat /auto/Sample_output/tmp.$F[0].vcf >> Sample_90061.vcf\");'",sep="")
Adam Stelmaszczyk
  • 19,665
  • 4
  • 70
  • 110
  • 1
    Yes. Sometimes it possible to include `"` if the string is enclosed in single-quotes, but didn't try it here since this answer is "more correct". – IRTFM Jan 08 '13 at 04:59