1

Goal: Retain in ss16wa only those rows where "COW" (a column name) is 1, 6, or 7.

I tried using COW == 1 || COW ==6 || COW == 7 which ran into errors. The image below, line 33, shows the new option that I have used which seems to work, but also cause an warning message of some sort.

If anyone knows a better solution then it will be much appreciated. enter image description here

Jaap
  • 81,064
  • 34
  • 182
  • 193
Dianna Li
  • 121
  • 6

1 Answers1

1

We can use %in% in the filter statement as == is used for comparing with a single element (or length equals 1). For more than one element in a vector, use %in%

library(dplyr)
filter(ss16wa, WAGP < 50000, SEMP< 50000, PINCP < 100000, COW %in% c(1, 6, 7))
akrun
  • 874,273
  • 37
  • 540
  • 662