Be careful with missing data using subsetting!
filter()
removes missing values by default. Because R can’t tell for sure if an NA
value meets the condition. To keep them need to add is.na()
conditional.
Think about if this is OK or not - it depends on your data!
airquality %>% filter(Solar.R > 330 | is.na(Solar.R))
Ozone Solar.R Wind Temp Month Day
1 NA NA 14.3 56 5 5
2 28 NA 14.9 66 5 6
3 7 NA 6.9 74 5 11
4 14 334 11.5 64 5 16
5 NA NA 8.0 57 5 27
6 NA 332 13.8 80 6 14
7 78 NA 6.9 86 8 4
8 35 NA 7.4 85 8 5
9 66 NA 4.6 87 8 6