Thank you Barry, this explains some of the things going on on the different platforms. One of my colleague told me some time ago that in C#/.NET they have this "raw string" functionality as you call it. However there they use @ and not r. That could be a nice thing to have in R.

Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling

Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
frtog@vestas.com<mailto:frtog@vestas.com>
http://www.vestas.com<http://www.vestas.com/>

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice<http://www.vestas.com/legal/notice>
If you have received this e-mail in error please contact the sender.

From: b.rowlingson@gmail.com [mailto:b.rowlingson@gmail.com] On Behalf Of Barry Rowlingson
Sent: 8. april 2014 17:40
To: Frede Aakmann Tøgersen
Cc: Jonathan Greenberg; r-help
Subject: Re: [R] Ignore escape characters in a string...



On Tue, Apr 8, 2014 at 4:30 PM, Frede Aakmann Tøgersen <frtog@vestas.com<mailto:frtog@vestas.com>> wrote:

I'm a bit surprised about the \\ on a linux OS. I'm also surprised that in a file manager on Windows you can paste e.g. C:/users/frtog/Desktop and it can find its way to the folder. Weird.


 Well, the clipboard contained a path separated by single backslashes. R read that (via the file("clipboard")) and correctly read single backslashes. Its only when printed out that R 'escapes' them as double-backslashes - there's really only one character there.
 What R seems to lack is 'raw string'  functionality. In python you do this with a string quote prefix, for example 'r':

 >>> len("\t")
 1
 In that case the \t is interpreted as a single character, \t, or tab. Add the "r" modifier:

>>> len(r"\t")
2
and now you get two characters, backslash and t.
You'll often see regular expressions in Python using raw strings since they tend to contain slashes and backslashes which you really want in there.
Barry


	[[alternative HTML version deleted]]


