Re: [R] regular expression

From: array chip <arrayprofile_at_yahoo.com>
Date: Thu, 31 Mar 2011 18:06:41 -0700 (PDT)

Ok then this code didn't do what I wanted. I want "not including 'arg' before '.symptom'", not individual letters of "arg", but rather as a word.

Bill Dunlap suggested using invert=T, it works for single 1 condition, but not for 2 conditions here: not including "arg" before ".", but at the same time, does include ".symptom".

Any other suggestions would be appreciated

John



From: Peter Langfelder <peter.langfelder_at_gmail.com>

Cc: Bernd Weiss <bernd.weiss_at_uni-koeln.de>; r-help_at_r-project.org Sent: Thu, March 31, 2011 5:55:26 PM
Subject: Re: [R] regular expression

> Thanks Bernd! I tried your approach with my real example, sometimes it worked,
> sometimes it didn't. For example
>
> grep('[^(arg)]\\.symptom',"stomach.symptom",value=T)
> [1] "stomach.symptom"
>
> grep('[^(arg)]\\.symptom',"liver.symptom",value=T)
> character(0)
>
> I think both examples should return the text, but the 2nd example didn't.
>
> What was wrong here?

Operator error :) Since you exclude 'r' before the '.', liver.symptom does not match the pattern.

Peter

        [[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. Received on Fri 01 Apr 2011 - 01:09:07 GMT

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 01 Apr 2011 - 01:40:27 GMT.

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

list of date sections of archive