Hello, Banging my head against a wall here ... can anyone light the way to a pattern modification that would make the following TRUE? identical( grep( "^Intensity\\s[^HL]", c("Intensity","Intensity L", "Intensity H", "Intensity Rep1")), as.integer(c(1,4))) Thank you for your time. Sincerely, Joh
try this:> identical(+ grep( + "^Intensity *[HL]", + c("Intensity","Intensity L", "Intensity H", "Intensity Rep1"), + invert = TRUE), + as.integer(c(1,4))) [1] TRUE>On Wed, May 1, 2013 at 4:37 AM, Johannes Graumann <johannes_graumann@web.de>wrote:> Hello, > > Banging my head against a wall here ... can anyone light the way to a > pattern modification that would make the following TRUE? > > identical( > grep( > "^Intensity\\s[^HL]", > c("Intensity","Intensity L", "Intensity H", "Intensity Rep1")), > as.integer(c(1,4))) > > Thank you for your time. > > Sincerely, Joh > > ______________________________________________ > R-help@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 Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. [[alternative HTML version deleted]]
Hello, The following pattern seems to do it. grep("^Intensity$|^Intensity\\s[^HL]", c("Intensity","Intensity L", "Intensity H", "Intensity Rep1")) Hope this helps, Rui Barradas Em 01-05-2013 09:37, Johannes Graumann escreveu:> Hello, > > Banging my head against a wall here ... can anyone light the way to a > pattern modification that would make the following TRUE? > > identical( > grep( > "^Intensity\\s[^HL]", > c("Intensity","Intensity L", "Intensity H", "Intensity Rep1")), > as.integer(c(1,4))) > > Thank you for your time. > > Sincerely, Joh > > ______________________________________________ > 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. >
HI, You could also do: vec1<- c("Intensity","Intensity L", "Intensity H", "Intensity Rep1") identical(setdiff(seq_along(vec1),grep("H|L",vec1)),as.integer(c(1,4))) #[1] TRUE A.K. ----- Original Message ----- From: Johannes Graumann <johannes_graumann at web.de> To: r-help at stat.math.ethz.ch Cc: Sent: Wednesday, May 1, 2013 4:37 AM Subject: [R] grep help (character ommission) Hello, Banging my head against a wall here ... can anyone light the way to a pattern modification that would make the following TRUE? identical( ? grep( ? ? "^Intensity\\s[^HL]", ? ? c("Intensity","Intensity L", "Intensity H", "Intensity Rep1")), ? as.integer(c(1,4))) Thank you for your time. Sincerely, Joh ______________________________________________ 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.