> DF <- data.frame(pat = letters[1:3]) > grep(paste(DF$pat, collapse = "|"), letters, value = TRUE) [1] "a" "b" "c"
On 10/16/06, Stéphane CRUVEILLER <[EMAIL PROTECTED]> wrote: > Ooops sorry for html tags... Just forgot to edit the message > before sending it... > So back to my question: > > Thx for the hint, but what would I have used if "b","c" and "d" > were values of a dataframe for instance? > > X is for instance a dataframe: > >X > Mypatterns > 1 pattern1 > 2 pattern2 > 3 pattern3 > > Y is another dataframe. > > If I do: > > grep(X$Mypatterns,Y) this will take into account only the first pattern... > I could use a loop but I vaguely remember an elegant trick that combined > grep and %in%. > > > Stéphane. > > ______________________________________________ [email protected] 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.
