[R] How to convert "c:\a\b" to "c:/a/b"?
Mulholland, Tom
Tom.Mulholland at dpi.wa.gov.au
Tue Jun 28 06:24:35 CEST 2005
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Henrik Bengtsson
> Sent: Tuesday, 28 June 2005 2:54 AM
> To: Spencer Graves
> Cc: r-help at stat.math.ethz.ch; Dirk Eddelbuettel
> Subject: Re: [R] How to convert "c:\a\b" to "c:/a/b"?
>
... snipped
> Thus, you cannot write your program such that it fools the parser,
> because your program is evaluated first after the parser. In other
> words, there is no way you can get nchar("\n") to equal 2.
>
I had been waiting for this answer because it was the conclusion I had come to. Given that I mainly work in a windows world this has been a problem. For various reasons I receive files liberally sprinkled with such pathnames. I generally pre-process them using whatever is at hand. It's not a big problem, just annoying to have to explain to collegues that this is something R can't do. Not a good advertisment for those who have no idea about escape codes.
However I can't believe that this problem cannot be solved. The thoughts that have come through my head are to write a c routine that effectively ignores the possibility that \n means newline and thus remaps all the escape codes into text (\\ and the character code.)
I've never written in C which is one of the reasons that I have never attempted this. I would be interested in any thoughts about the viability of my proposal. It seems an awful lot of work (at least for someone who hasn't done this sort of stuff before) for something that can be achieved in many other ways.
Tom
More information about the R-help
mailing list