On 29/03/2010 5:14 PM, Matthew Keller wrote:
Hi all,

I would like to run the following from within R:

awk '{$3=$4="";gsub("  ","");print}' myfile > outfile

However, this obviously won't work:
system("awk '{$3=$4="";gsub("  ","");print}' myfile > outfile")

and this won't either:
system("awk '{$3=$4='';gsub('  ','');print}' myfile > outfile")


Can anyone help me out? I'm sure there's an obvious solution. Thanks,

Escape the quotes that match the ones you use in R:

system("awk '{$3=$4=\"\";gsub(\"  \",\"\");print}' myfile > outfile")

or

system('awk \'{$3=$4="";gsub("  ","");print}\' myfile > outfile')

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to