using perl regular expression
Do it in two steps:
x <- c("NEQ23", "NHQ29", "NGQ00", "NFQ123")
pat <- "N[E-H]Q[0-9]{2}"
bad <- "N[E-H]Q29"
all <- grep(pat, x, perl=TRUE)
x29 <- grep(bad, x, perl=TRUE)
setdiff(all, x29)
[1] 1 3 4
On Tue, Feb 24, 2009 at 7:57 AM, Katrine Damgaard
<Katrine.Damgaard at kunnskapssenteret.no> wrote:
Hello everybody!
I'm using Perl regular Expression for find pattern in my data set.
The pattern is: NaQxy, where a=E, F, G or H and xy != 29. I have tried this:
pattern <- "^N[E-H]Q[0-9]{2,2}"
index <- grep(pattern, X, perl=T) ? #where X is my vector
But the problem is the xy should not be 29. How can I solve this problem.
Thanks!!!
Regards,
Katrine
? ? ? ?[[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.
Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?