[R] Question Regarding 'pipe'

Jan T. Kim jtk at cmp.uea.ac.uk
Tue Apr 8 11:45:10 CEST 2008

On Mon, Apr 07, 2008 at 07:42:50PM -0500, born.to.b.wyld at gmail.com wrote:
> Can anyone point out why this is not working?
> y<-read.table(pipe('  awk '{ n = $1; sub( ".*" $1 " " ,"") ; while ( n-- )
> print }'  temp.txt '))

one problem is that your single-quoted R string contains single quotes
which I've pointed to with "^" above. You probably intend these single
quotes to be part of the awk command line, but R can\'t know that unless
you escape them...  ;-)

In the future, can you please describe explicitly how it "is not working",
and also give a bit more context, such as a few lines of description of
the content of temp.txt, and why you're trying to use awk (rather than R
itself) to achieve whatever you're trying to achieve?

Best regards, Jan
 +- Jan T. Kim -------------------------------------------------------+
 |             email: jtk at cmp.uea.ac.uk                               |
 |             WWW:   http://www.cmp.uea.ac.uk/people/jtk             |
 *-----=<  hierarchical systems are for files, not for humans  >=-----*

More information about the R-help mailing list