Message-ID: <Pine.LNX.4.44.0305201232250.10083-100000@gannet.stats>
Date: 2003-05-20T11:37:48Z
From: Brian Ripley
Subject: Output to connections
In-Reply-To: <20030520112726.205437CA824@tango.stat.unipd.it>
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