[R] pasting "\" into character strings
Thomas Lumley
tlumley at u.washington.edu
Mon Dec 23 17:25:04 CET 2002
On Sun, 22 Dec 2002, John Miyamoto wrote:
>
> I discovered from this interchange that I did not quite state my problem
> correctly, but the discussion solved the real problem as well as the
> stated problem. What started me on these questions was the desire to
> write a function that would convert a R-intelligible file reference, e.g.,
> 'c:/work/part1.txt' to a Windows file reference, e.g.,
> 'c:\work\part1.txt'. Having gotten this big hint, I now see how to solve
> the problem as shown in the following:
>
a) You very rarely need to do this conversion. R (and a lot of other
Windows software) is perfectly happy with c:/work/part1.txt
b) An easier way to convert is to use chartr()
> chartr("/","\\","c:/work/part1.txt")
[1] "c:\\work\\part1.txt"
-thomas
More information about the R-help
mailing list