[R] \ escape sequence and windows path

peter dalgaard pdalgd at gmail.com
Tue May 20 14:28:50 CEST 2014


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.

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list