[R] \ escape sequence and windows path
David L Carlson
dcarlson at tamu.edu
Tue May 20 19:00:41 CEST 2014
Now I understand. Not really a solution, but you can instruct students to use only forward slashes in their paths since R will convert to backslash on Windows systems automatically. After a couple of broken commands, they should get the hang of it.
David C
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Knut Krueger
Sent: Tuesday, May 20, 2014 11:05 AM
To: r-help at r-project.org
Subject: Re: [R] \ escape sequence and windows path
Am 20.05.2014 17:32, schrieb Bert Gunter:
>> paste("a","b",sep="\\") ## "\\" is the escaped single backslash
> [1] "a\\b"
>> cat(paste("a","b",sep="\\"))
> a\b
>
> Does this help clarify? Or have i misunderstood you?
@David and @Bert
unfortunately yes. My question is more a system level question as about
any converting functions.
The question is how to paste a windows path directly into an R script
(without readline() or readClipboard() and how could I convert this
string that it is usable in R. Means any function which is not using
escape characters
it seems to be possible for readline() an readClipboard().
I do not want to use y=readline() I do want to use
y=foo("c:\foo1\foo2\") but this seems to be impossible because R is
interpreting one backslash as escape sequence. So how does readline()
and readClipboard() are working? Is there any other callback from utils
which is able to deal with this?
I am afraid there is no way.
The reason is to prevent errors for beginning windows R user. If the
path is long they either forget to convert one backslash or all and then
they are frustrated that it is not working. And telling them to use
search and replace ... Whatever they would replace it might be worse
than before ;-)
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