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

From: Berwin A Turlach <Berwin.Turlach_at_gmail.com>
Date: Sun, 08 May 2011 17:18:55 +0800

G'day Dan,

On Sun, 8 May 2011 05:06:27 -0400
Dan Abner <dan.abner99_at_gmail.com> 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 !"

Try (untested)

R> data2[!(data1$char1 %in% c("string1","string2")),1]<-max(data1$x1)+1000

HTH. Cheers,

        Berwin



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 - 09:21:10 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 - 12:10:05 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