[R] Replacing backslashes with slashes

yvonnick noel yvonnick.noel at uhb.fr
Wed Jan 4 12:02:13 CET 2006


Hello,

I've seen this question asked in the archives but no clear reply or solution
provided. So, just to be sure it is not possible in R: Can I replace
backslashes with slashes in a string ?

I am writing a GUI for R with the Rpad library. I have a "browse" button for
data loading and Windows return a path string with backslashes. I need to
convert them into slashes to use the string with read.table.

I would have expected something like:

gsub("\\","\/","c:\My Documents\data.dat")

to work but it does not (incorrect regular expression).

Note that I have no control on the string which is returned from the system (no
such problem under Linux BTW).

Any idea ?

Yvonnick NOEL
U. of Rennes 2
FRANCE




More information about the R-help mailing list