Re: [R] %in% operator - NOT IN

From: Duncan Mackay <mackay_at_northnet.com.au>
Date: Sun, 08 May 2011 22:52:24 +1000

At 19:06 08/05/2011, you wrote:
>Hello everyone,
>
>I am attempting to use the %in% operator with the ! to produce a NOT IN type
>of operation. Why does this not work? Suggestions?

>
> > data2[data1$char1 %in% c("string1","string2"),1]<-min(data1$x1)
> > data2[data1$char1 ! %in% c("string1","string2"),1]<-max(data1$x1)+1000
>
>Error: unexpected '!' in "data2[data1$char1 !"
>
>
>Thanks!
>
>Dan
>
>XXXX
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help_at_r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

Hi Dan

See the last of the examples for ?match

"%w/o%" <- function(x, y) x[!x %in% y] #-- x without y (1:10) %w/o% c(3,7,12)

I think it was Peter Dalgaard who pointed this out some years ago

HTH Regards

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email: home mackay_at_northnet.com.au



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 08 May 2011 - 12:58:45 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 08 May 2011 - 14:20:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive