Matthew Keller
2010-Mar-29 21:14 UTC
[R] single quotes and double quotes in a system() command. What to do?
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, Matt -- Matthew C Keller Asst. Professor of Psychology University of Colorado at Boulder www.matthewckeller.com
Duncan Murdoch
2010-Mar-29 21:39 UTC
[R] single quotes and double quotes in a system() command. What to do?
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
Possibly Parallel Threads
- skip non-sequential lines using scan?
- how to make read in a vector of 0s and 1s with no space between them
- Changing the name of the "R" process in top
- ideas about how to reduce RAM & improve speed in trying to use lapply(strsplit())
- maximum elements in an ff object?