? backslash was Re: [R] Editor alternative

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Sep 13 14:51:03 CEST 2000


On Wed, 13 Sep 2000, Yves Gauvreau wrote:

> 
> ----- Original Message -----
> From: "Uwe Ligges" <ligges at statistik.uni-dortmund.de>
> To: "Yves Gauvreau" <cyg at sympatico.ca>
> Sent: Wednesday, September 13, 2000 7:19 AM
> Subject: Re: ? backslash was Re: [R] Editor alternative
> 
> 
> > Yves Gauvreau wrote:
> > >
> > > Hi
> > >
> > > I just want to point out an observation. I noticed that path strings
> under
> > > Windows required that I double up the backslash "\" as it is used as an
> > > escape character as in C. I think that most if not all of the "Unix
> tools"
> > > ported to Windows accept path strings with a single backslash. I wonder
> if
> > > it would be worthwhile to reproduce that behavior under R somehow? I
> mean
> > > kind of preprocessing the params used as path strings transparently
> since
> > > character vectors don't "escape" the backslash.
> > >
> > > I understand it is much easier to require from users of R under Windows
> to
> > > comply with it's path strings needs. Maybe it would be nice to just
> provide
> > > a simple function in "base" for the sole purpose of translating Windows
> path
> > > strings to the required form.
> >
> > I don't think, it is necessary. It is not so difficult to use "/" or
> > "\\" instead of "\" ...
> >
> > Uwe Ligges
> 
> I agree when you have a single path string to process it's ain't worth the
> trouble but what about situations where say you make use of a large number
> of Windows path string stored in a file or anywhere else and you want to
> process each of the files the path string points to? I think a more generic
> solution might be appropriate. Of course if no one as the need to process a
> large number of files in various directory on it's file system under Windows
> then this thread is dead in the water. Also if the number of people with
> such needs is small they probably already have implemented a solution to
> their problem.
> 
> I just though that a function in base for such problem would have been a
> nice consideration to us Windows users. No offence intended to the rest of
> the world.

Use gsub, as in several R system utils. I think

newpath <- gsub("\\", "/", oldpath)

does what you want.  (You could convert to \\\\ if you prefer.)

In general \ does matter in strings (\n, \t etc) so we can't avoid
the need to double \.


-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list