[R] Output to connections

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue May 20 13:37:48 CEST 2003


On Tue, 20 May 2003, Adelchi Azzalini wrote:

> On Tuesday 20 May 2003 13:03, Henrik Bengtsson wrote:
> > In R '\' has to be escaped, i.e. '\\' which means '\\' has to be '\\\\'
> > (this was probably there before the help page was generated!?)

Um, that's not the problem.  If this is a Unix-alike, the shell invoked by
popen also (probably, depending on the shell) needs "\" escaped. So each
of

the help processing
R strings
the Unix shell (probably)

need \ doubled (probably), and it is the last one I forgot.

> >
> > The following works
> >
> >   ## convert decimal point to comma in output, using a pipe (Unix)
> >   zz <- pipe(paste("sed s/\\\\./,/ >", "outfile"), "w")
> >   cat(format(round(rnorm(100), 4)), sep = "\n", file = zz)
> >   close(zz)
> >   ## now look at the output file:
> >   file.show("outfile", delete.file = TRUE)
> 
> Yes, it works, thanks
> 
> Adelchi
> 
> 

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list