On Wed, Sep 24, 2008 at 9:59 AM, Shengqiao Li <[EMAIL PROTECTED]> wrote: > > On Wed, 24 Sep 2008, jim holtman wrote: > >> It probably depends on how you are prompting the user for input. Here >> is what happens with 'readline' and you will see that the string after >> input does have the backslashes escaped. >> >>> x <- readline("Input File: ") >> >> Input File: c:\dir1\dir2\file.name >>> >>> x >> >> [1] "c:\\dir1\\dir2\\file.name" >>> >>> gsub("\\\\", "/", x) # notice the double escape >> >> [1] "c:/dir1/dir2/file.name" >>> > > Great! Thanks. By the way, it would be nice if R have a third way to quote a > string and automatically escape the backslashes in memory. For instance: > > #not run now > s<- `C:\Acer' > > print(s) > [1] "C:\\Acer"
I agree that that some sort of facility would be convenient. Creating latex output is another situation where not having to escape backslashes would be convenient. Other languages do have special purpose constructs for this. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.