[R] grep negation

james.holtman@convergys.com james.holtman at convergys.com
Thu Jun 23 15:04:14 CEST 2005





?setdiff

e.g.,

> txt <- c("arm","foot","lefroo", "bafoobar")
> i <- grep("foo",txt); i
[1] 2 4
> setdiff(seq(length(txt)),grep("foo",txt))
[1] 1 3
>


Jim
__________________________________________________________
James Holtman        "What is the problem you are trying to solve?"
Executive Technical Consultant  --  Convergys Labs
james.holtman at convergys.com
+1 (513) 723-2929


                                                                                                                                           
                      Marcus Leinweber                                                                                                     
                      <leinwebe at eva.mpg.de>        To:       "'r-help at stat.math.ethz.ch'" <r-help at stat.math.ethz.ch>                       
                      Sent by:                     cc:                                                                                     
                      r-help-bounces at stat.m        Subject:  [R] grep negation                                                             
                      ath.ethz.ch                                                                                                          
                                                                                                                                           
                                                                                                                                           
                      06/23/2005 08:59                                                                                                     
                                                                                                                                           




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




More information about the R-help mailing list