[R] Logic operators...more than one??
Marc Schwartz
m@rc_@chw@rtz @end|ng |rom me@com
Thu Oct 4 01:06:48 CEST 2018
> On Oct 3, 2018, at 7:03 PM, David Doyle <kydaviddoyle using gmail.com> wrote:
>
> I'm sure this is a simple question but I'm not sure where to find the
> answer.
>
> I want to remove some of the data. For example when my Location column is
> MW-09, MW-10, or MW-11.
>
> It works fine if I ONLY list ONE of the locations as in:
>
> SampledWells <- MyData[ MyData$Location != "MW-09", ]
>
> But if I try to do more than one (as shown below), I don't get an error but
> I also don't get my SampledWells
> SampledWells <- MyData[ MyData$Location != "MW-09", "MW-10", ]
>
> Thoughts??
>
> Thank you for your time
> David
Hi,
See ?"%in%"
Then:
SampledWells <- MyData[ !MyData$Location %in% c("MW-09", "MW-10"), ]
Note the '!' operator that precedes the expression to negate the logical.
Regards,
Marc Schwartz
[[alternative HTML version deleted]]
More information about the R-help
mailing list