[R] grep negation

Don MacQueen macq at llnl.gov
Thu Jun 23 17:15:12 CEST 2005


If all you need to do is extract the subset of elements of txt that 
do not contain 'foo', then

   txt[-i]

will do the job. Provided that at east one element of txt contains 
'foo', that is.

-Don

At 2:59 PM +0200 6/23/05, Marcus Leinweber wrote:
>hi,
>
>using the example in the grep help:
>txt <- c("arm","foot","lefroo", "bafoobar")
>i <- grep("foo",txt); i
>[1] 2 4
>
>but how can i get the negation (1,3) when looking for 'foo'?
>
>thanks,
>m.
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA




More information about the R-help mailing list