Re: [R] grep negation

From: <james.holtman_at_convergys.com>
Date: Thu 23 Jun 2005 - 23:04:14 EST

?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@convergys.com
+1 (513) 723-2929
                                                                                                                                           
                      Marcus Leinweber                                                                                                     
                      <leinwebe@eva.mpg.de>        To:       "'r-help@stat.math.ethz.ch'" <r-help@stat.math.ethz.ch>                       
                      Sent by:                     cc:                                                                                     
                      r-help-bounces@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@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

R-help@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 Received on Thu Jun 23 23:07:22 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:58 EST