[R] url prep function (backslash issue)
Duncan Murdoch
murdoch.duncan at gmail.com
Tue Aug 30 15:35:58 CEST 2011
Brian Ripley told you how to do the translation, but there's another
problem:
On 30/08/2011 8:14 AM, Tyler Rinker wrote:
[ much deleted ]
> When I try
> the function the backslash gets me again:
>
> >
> readyPath("C:\Users\Rinker\Desktop\Research& Law\Data\School Data
> 09-10")
The problem is that you haven't entered a string containing backslashes,
you've tried to enter a string containing escapes. The parser sees a
single backslash and attaches it to the next letter, so \U is taken to
be the start of a Unicode character, and you get the error
> Error: '\U' used without hex digits in character string starting
> "C:\U"
>
The way around this is to avoid the parser, by something like this:
oldstring <- readline()
C:\Users\Rinker\Desktop\Research& Law\Data\School Data 09-10
and then applying chartr to oldstring.
Duncan Murdoch
> This is
> what I'd like the function to return:
>
> [1]
> "C:/Users/Rinker/Desktop/Research& Law/Data/School Data 09-10"
>
> I want a
> function in which I enter a path and it returns the path with backslashes
>
> replaced
> with forward slashes. Is there a way to make a function to do this?
>
> Windows 7
> user
>
> R version
> 2.14 beta
>
> Thank you,
>
> Tyler
> Rinker
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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