Re: [Rd] gsub("\\", "\\\\", "C:\Program Files\R")

From: Uwe Ligges <ligges_at_statistik.tu-dortmund.de>
Date: Fri, 12 Aug 2011 14:14:06 +0200

On 12.08.2011 10:52, mafia88 wrote:
> Hi,
>
> I think it is not possible in R but I rather ask before giving up:
>
> What I have: I have copied "C:\Program Files\R" into my clipboard.
> What I want: setwd(transform("C:\Program Files\R")) where the function
> transform should change the "C:\Program Files\R" from my clipboard to
> "C:\\Program Files\\R" so that R can handle it. Is this possible?
> I've tried with gsub("\\", "\\\\", "C:\Program Files\R") but failed, then
> tried first to split the full clipboard string cause \P is reserved in R but
> with strsplit("C:\Program Files\R", "") I also failed.
>
> Therefore the question: It is really necessary to manually add a second "\"
> in "C:\Program Files\R", so that setwd("C:\\Program Files\\R") can change my
> work directory?
> Cause I am getting tired making this manually... yes I know I can use the
> Search&Replace function from the Editor but I thought R can do everything?
>
> I hope someone could help me :(

Not really: You need to get it "transformed" before the R parser has its hand on it, therefore the best solution is to ask your editor to do that.

Uwe Ligges

> --
> View this message in context: http://r.789695.n4.nabble.com/gsub-C-Program-Files-R-tp3738251p3738251.html
> Sent from the R devel mailing list archive at Nabble.com.
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 12 Aug 2011 - 12:16:34 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 12 Aug 2011 - 12:20:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive