Re: [R] Replacing backslashes with slashes

From: Elizabeth Lawson <lizzylaws_at_yahoo.com>
Date: Thu 05 Jan 2006 - 03:00:38 EST


Try    

> name<-"C:\\myfile.txt"
> name

[1] "C:\\myfile.txt"
> gsub("([\\])","\\/",name)

[1] "C:/myfile.txt"

yvonnick noel <yvonnick.noel@uhb.fr> wrote:   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



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html                            

 Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jan 05 03:41:51 2006

This archive was generated by hypermail 2.1.8 : Thu 05 Jan 2006 - 05:29:26 EST