[R] \ escape sequence and windows path

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Tue May 20 15:22:14 CEST 2014


Most importantly, "\\" is a string literal containing ONE backslash character. Yes you can create strings in R source code that represent Windows-style paths, but they must APPEAR different in that context. You may find it helpful to know that the print function can output escaped strings suitable for inclusion in R code, while the cat function can output those same strings without the escaping.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On May 20, 2014 5:28:50 AM PDT, peter dalgaard <pdalgd at gmail.com> wrote:
>
>On 20 May 2014, at 12:37 , Knut Krueger <rh at knut-krueger.de> wrote:
>
>> 
>> Is there any function to change the windows path to linux path?
>> 
>> especially I would like to have the possibility to use
>> f.e
>> path="C:\foo1\foo2\"
>> I can import those paths with
>> path = readline()  but not directly in a script
>> 
>
>In R string specifications, \ is an escape character. \n is newline, \b
>rings the bell, \" is a double quote, etc. So "C:\foo1\foo2\" is
>unterminated and containes 2 form feed characters. 
>
>There's no way around using \\ to specify a backslash in a string
>literal.  For file paths, you can also use the forward slash instead of
>the backslash.
>
>> Regards Knut
>> 
>> ______________________________________________
>> R-help at 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.



More information about the R-help mailing list