Re: [R] detect escape character

2014-06-05 Thread Adrian Dușa
On Tue, Jun 3, 2014 at 8:44 PM, David Winsemius wrote: > > On Jun 3, 2014, at 11:03 AM, Adrian Dușa wrote: > >> Dear All, >> >> I should be knowing this, but not get it right... > > I'm a little surprised to see you ask this, too, but we each have lacunae in > our R knowledge, so I hope this help

Re: [R] detect escape character

2014-06-05 Thread Frede Aakmann Tøgersen
lants, better than nuclear power plants :-) Best regards Frede Sendt fra Samsung mobil Oprindelig meddelelse Fra: peter dalgaard Dato:05/06/2014 13.15 (GMT+01:00) Til: Sarah Goslee Cc: Frede Aakmann Tøgersen ,r-help@r-project.org,Adrian Dușa Emne: Re: [R] detect escape char

Re: [R] detect escape character

2014-06-05 Thread peter dalgaard
You'll find it even more entertaining to realize that Frede's _previous_ position (at Department of Genetics and Biotechnology, Faculty of Agricultural Sciences, Aarhus University) was quite a bit closer to yours. ;-) -pd On 03 Jun 2014, at 20:37 , Sarah Goslee wrote: >> >> Frede Aakmann Tøg

Re: [R] detect escape character

2014-06-03 Thread David Winsemius
On Jun 3, 2014, at 11:03 AM, Adrian Dușa wrote: > Dear All, > > I should be knowing this, but not get it right... I'm a little surprised to see you ask this, too, but we each have lacunae in our R knowledge, so I hope this helps: > s <- scan(what="") # Assuming you were asking about items co

Re: [R] detect escape character

2014-06-03 Thread Jeff Newmiller
With the right mental model, though, it can become intuitive. That is, keep in mind that the R interpreter uses \ as a metacharacter, and so does the regex library. You want to search for a \, which regex thinks is special, so you have to escape it for regex functions (\\). Then, because R think

Re: [R] detect escape character

2014-06-03 Thread Sarah Goslee
rah > > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] >> On Behalf Of Sarah Goslee >> Sent: 3. juni 2014 20:18 >> To: Adrian Dușa >> Cc: r-help@r-project.org >> Subject: Re: [R] detect escape c

Re: [R] detect escape character

2014-06-03 Thread Frede Aakmann Tøgersen
f Sarah Goslee > Sent: 3. juni 2014 20:18 > To: Adrian Dușa > Cc: r-help@r-project.org > Subject: Re: [R] detect escape character > > Hi, > > R uses \ as a metacharacter, so you need a non-intuitive number of \: > > > mystring <- "Man\\Woman" > # \\ is

Re: [R] detect escape character

2014-06-03 Thread Sarah Goslee
Hi, R uses \ as a metacharacter, so you need a non-intuitive number of \: mystring <- "Man\\Woman" # \\ is a metacharacter and a \, so it's equivalent to \ in normal text sub("", "/", mystring) Sarah On Tue, Jun 3, 2014 at 2:03 PM, Adrian Dușa wrote: > Dear All, > > I should be knowing

[R] detect escape character

2014-06-03 Thread Adrian Dușa
Dear All, I should be knowing this, but not get it right... For a string like this: "Man\Woman" I would like to detect the escape character "\" and replace it with "/". Tried various ways using gsub(), but don't get it right yet. Any suggestion would be highly welcomed... Thank you, Adrian --