[R] How to convert "c:\a\b" to "c:/a/b"?

Dirk Eddelbuettel edd at debian.org
Mon Jun 27 06:09:01 CEST 2005


On 26 June 2005 at 20:30, Spencer Graves wrote:
| 	  How can one convert back slashes to forward slashes, e.g, changing 
| "c:\a\b" to "c:/a/b"?  I tried the following:
| 
|  > gsub("\\\\", "/", "c:\a\b")
| [1] "c:\a\b"

This does work, provided you remember that single backslashed "don't exist"
as e.g. \a is a character in itself. So use doubles are you should be fine:

> gsub("\\\\", "/", "c:\\a\\b")
[1] "c:/a/b"

Hth, Dirk

-- 
Statistics: The (futile) attempt to offer certainty about uncertainty.
         -- Roger Koenker, 'Dictionary of Received Ideas of Statistics'




More information about the R-help mailing list