On Tue, Apr 8, 2014 at 4:30 PM, Frede Aakmann Tøgersen <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]]


