Dear all, Below there are two, simple - I suppose, questions on using pmatch():> pmatch("xx", c("cc","xxa"))[1] 2> pmatch("a", c("cc","xxa"))[1] NA> pmatch("xx", c("cc","xxa","xxb"))[1] NA I would like that the second call returns also 2, and the third call returns c(2,3) is it possible? many thanks vito
Vito Muggeo wrote:> Dear all, > Below there are two, simple - I suppose, questions on using pmatch(): > > >>pmatch("xx", c("cc","xxa")) > > [1] 2 > >>pmatch("a", c("cc","xxa")) > > [1] NA > >>pmatch("xx", c("cc","xxa","xxb")) > > [1] NA > > I would like that the second call returns also 2, and the third call returns > c(2,3) > is it possible?You are looking for grep(). Uwe Ligges> many thanks > vito > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>>>>> "Vito" == Vito Muggeo <vito.muggeo at giustizia.it> >>>>> on Thu, 2 Oct 2003 11:03:38 +0200 writes:Vito> Dear all, Vito> Below there are two, simple - I suppose, questions on using pmatch(): >> pmatch("xx", c("cc","xxa")) Vito> [1] 2 >> pmatch("a", c("cc","xxa")) Vito> [1] NA >> pmatch("xx", c("cc","xxa","xxb")) Vito> [1] NA Vito> I would like that the second call returns also 2, and Vito> the third call returns c(2,3) is it possible? yes, if you use grep() instead of pmatch() {and grep() *is* mentioned in the "See Also" section of help(pmatch) which you have consulted before asking, right ?} Vito> many thanks you're welcome. Martin