Re: [R] Replacing backslashes with slashes

From: yvonnick noel <yvonnick.noel_at_uhb.fr>
Date: Thu 05 Jan 2006 - 03:34:11 EST

> You need one of
>
> gsub("\\\\","/","c:\\My Documents\\data.dat")
> gsub("\\","/","c:\\My Documents\\data.dat", fixed = TRUE)
> chartr("\\", "/", "c:\\My Documents\\data.dat")

The string I get is an ASCII string in a web page, through the use of an <INPUT
type="file" ... > tag (with a "browse" button). This string is caught as is by R through the Rpad interface (using tcltk as a mini local webserver).

So it is not manually input by the user. As it appears in a textfield on a web page, I could of course ask the user to change it manually and double the antislashes. But this is not user-friendly.

>> Note that I have no control on the string which is returned from the
>> system (no such problem under Linux BTW).
>
> Really? What happens with file names containing backslashes on Linux?

I just meant no conversion was needed under Linux since pathnames use slashes. That's why I didn't see this problem until I had my student use the graphical interface under Windows.

Thank you,

Yvonnick.



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 05:03:08 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:50 EST