[R] %in% operator - NOT IN

baptiste auguie baptiste.auguie at googlemail.com
Sun May 8 11:25:09 CEST 2011


Hi,

On 8 May 2011 21:18, Berwin A Turlach <Berwin.Turlach at gmail.com> wrote:
> 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?

Alternatively,

example(`%in%`)

or

`%ni%` = Negate(`%in%`)

HTH,

baptiste

>>
>> > 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.
>



More information about the R-help mailing list