Jana
Jana

Reputation: 1555

Adding ' " ' quote inside a paste command in R

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?

Upvotes: 1

Views: 18172

Answers (1)

Adam Stelmaszczyk
Adam Stelmaszczyk

Reputation: 19847

Escape " with backslash \. So you will have:

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

Upvotes: 4

Related Questions