[R] detect escape character
Frede Aakmann Tøgersen
frtog at vestas.com
Tue Jun 3 20:29:23 CEST 2014
Hhhhhmmmhhhhmm.
> mystring <- "Man\\Woman"
> cat(mystring)
Man\Woman>
>
> mystring <- "Man\Woman"
Fejl: '\W' is an unrecognized escape in character string starting ""Man\W"
>
So was the OP asking about?
We need some more information, thank you!.
Yours sincerely / Med venlig hilsen
Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling
Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
frtog at vestas.com
http://www.vestas.com
Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender.
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of Sarah Goslee
> Sent: 3. juni 2014 20:18
> To: Adrian Dușa
> Cc: r-help at 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 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 <dusa.adrian at unibuc.ro> wrote:
> > 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
> >
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>
> ______________________________________________
> 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