Re: [R] gsub: replacing double backslashes with single backslash

2012-03-08 Thread Ista Zahn
-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ista Zahn Sent: Wednesday, March 07, 2012 6:55 PM To: Greg Snow Cc: r-help@r-project.org; Markus Elze Subject: Re: [R] gsub: replacing double backslashes with single backslash On Wed, Mar 7, 2012 at 12:57 PM, Greg Snow 538

[R] gsub: replacing double backslashes with single backslash

2012-03-07 Thread Markus Elze
Hello everybody, this might be a trivial question, but I have been unable to find this using Google. I am trying to replace double backslashes with single backslashes using gsub. There seems to be some unexpected behaviour with regards to the replacement string \\. The following example uses

Re: [R] gsub: replacing double backslashes with single backslash

2012-03-07 Thread David Winsemius
On Mar 7, 2012, at 6:54 AM, Markus Elze wrote: Hello everybody, this might be a trivial question, but I have been unable to find this using Google. I am trying to replace double backslashes with single backslashes using gsub. Actually you don't have double backslashes in the argument you

Re: [R] gsub: replacing double backslashes with single backslash

2012-03-07 Thread Greg Snow
The issue here is the difference between what is contained in a string and what R displays to you. The string produced with the code: tmp - C:\\ only has 3 characters (as David pointed out), the third of which is a single backslash, since the 1st \ escapes the 2nd and the R string parsing

Re: [R] gsub: replacing double backslashes with single backslash

2012-03-07 Thread Ista Zahn
On Wed, Mar 7, 2012 at 12:57 PM, Greg Snow 538...@gmail.com wrote: The issue here is the difference between what is contained in a string and what R displays to you. The string produced with the code: tmp - C:\\ only has 3 characters (as David pointed out), the third of which is a

Re: [R] gsub: replacing double backslashes with single backslash

2012-03-07 Thread Jeff Newmiller
You are chasing your tail. You have already achieved your goal, but you don't seem to understand that. The three characters C:\ are represented in R as C:\\ so when you see the latter, the former is what is actually already in memory. C:\ is not legal R code (it is an unterminated string).

Re: [R] gsub: replacing double backslashes with single backslash

2012-03-07 Thread Daniel Nordlund
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ista Zahn Sent: Wednesday, March 07, 2012 6:55 PM To: Greg Snow Cc: r-help@r-project.org; Markus Elze Subject: Re: [R] gsub: replacing double backslashes with single backslash