0

I need to create a subset of my dataset that only includes birds with malaria = 0 and 1 (not 2) as well as exclude IIWI from the model.

I tried this:

datPox2 <- subset(datPox, Malaria = 0 & 1)
datPox2

But that didn't get rid of 2 in the Malaria column. I also can't figure out how to exclude the one species while leaving the other three.

Here is a sample of my data:

Site    Species Bandno  Date    Sex Age Oldpox  Activepox   Malaria Elev
1   AIN APAP    159174793   7/22/2004   U   H   0   0   2   mid
2   AIN APAP    159174964   7/6/2004    M   H   0   1   2   mid
3   AIN HAAM    165180406   3/1/2002    M   A   0   0   0   mid
4   AIN HAAM    165180406   7/2/2003    M   A   0   0   1   mid
5   AIN JAWE    224018088   6/18/2002   U   H   0   0   2   mid
6   AIN JAWE    224018089   6/18/2002   U   H   0   0   2   mid
7   KUL IIWI    151129162   4/29/1993   M   H   0   0   0   high
8   KUL IIWI    151129162   10/8/1993   M   H   0   0   0   high
9   KUL IIWI    151129162   3/7/1994    M   A   0   0   0   high
10  KUL IIWI    151129162   4/6/1994    M   A   0   0   0   high

1 Answers1

1

dplyr version

library(dplyr)

datPox %>%
  filter(Malaria  != 2)

   Site Species    Bandno      Date Sex Age Oldpox Activepox Malaria Elev
3   AIN    HAAM 165180406  3/1/2002   M   A      0         0       0  mid
4   AIN    HAAM 165180406  7/2/2003   M   A      0         0       1  mid
7   KUL    IIWI 151129162 4/29/1993   M   H      0         0       0 high
8   KUL    IIWI 151129162 10/8/1993   M   H      0         0       0 high
9   KUL    IIWI 151129162  3/7/1994   M   A      0         0       0 high
10  KUL    IIWI 151129162  4/6/1994   M   A      0         0       0 high

base R version

datPox[datPox$Malaria != 2,]

   Site Species    Bandno      Date Sex Age Oldpox Activepox Malaria Elev
3   AIN    HAAM 165180406  3/1/2002   M   A      0         0       0  mid
4   AIN    HAAM 165180406  7/2/2003   M   A      0         0       1  mid
7   KUL    IIWI 151129162 4/29/1993   M   H      0         0       0 high
8   KUL    IIWI 151129162 10/8/1993   M   H      0         0       0 high
9   KUL    IIWI 151129162  3/7/1994   M   A      0         0       0 high
10  KUL    IIWI 151129162  4/6/1994   M   A      0         0       0 high

Exclude IIWI

datPox %>%
  filter(Malaria  != 2, Species != "IIWI")

  Site Species    Bandno     Date Sex Age Oldpox Activepox Malaria Elev
3  AIN    HAAM 165180406 3/1/2002   M   A      0         0       0  mid
4  AIN    HAAM 165180406 7/2/2003   M   A      0         0       1  mid
Park
  • 14,771
  • 6
  • 10
  • 29