Re: [R] grep function with patterns list...

2006-10-17 Thread Martin Maechler
> "Anupam" == Anupam Tyagi <[EMAIL PROTECTED]> > on Mon, 16 Oct 2006 18:15:06 + (UTC) writes: Anupam> Hi Stephane, Anupam> Stéphane CRUVEILLER genoscope.cns.fr> writes: >> is there a way to pass a list of patterns to the grep function? I >> vaguely remember somethi

Re: [R] grep function with patterns list...

2006-10-16 Thread Anupam Tyagi
Hi Stephane, Stéphane CRUVEILLER genoscope.cns.fr> writes: > is there a way to pass a list of patterns to the grep function? I > vaguely remember something with %in% operator... I think you are looking for the %in% and %nin% which are part of Design package, and also in Hmisc library. You have t

Re: [R] grep function with patterns list...

2006-10-16 Thread Gabor Grothendieck
> 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 f

Re: [R] grep function with patterns list...

2006-10-16 Thread Stéphane CRUVEILLER
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 patte

Re: [R] grep function with patterns list...

2006-10-16 Thread Stéphane CRUVEILLER
Thx for the hint, but what would I have used if "b","c" and "d" were values of a dataframe for instance? Stéphane. Gabor Grothendieck a écrit : > Try this: > >> grep("b|c|d", letters, value = TRUE) > [1] "b" "c" "d" > > On 10/16/06, Stéphane CRUVEILLER <[EMAIL PROTECTED]> wrote: >> Dear R-users,

Re: [R] grep function with patterns list...

2006-10-16 Thread Gabor Grothendieck
Try this: > grep("b|c|d", letters, value = TRUE) [1] "b" "c" "d" On 10/16/06, Stéphane CRUVEILLER <[EMAIL PROTECTED]> wrote: > Dear R-users, > > is there a way to pass a list of patterns to the grep function? I > vaguely remember something with %in% operator... > > > Thanks, > > > Stéphane. > > >

[R] grep function with patterns list...

2006-10-16 Thread Stéphane CRUVEILLER
Dear R-users, is there a way to pass a list of patterns to the grep function? I vaguely remember something with %in% operator... Thanks, Stéphane. -- "La science a certes quelques magnifiques réussites à son actif mais à tout prendre, je préfère de loin être heureux plutôt qu'avoir raison.