In my data.frame below, I want to subset all rows for which group == 0
AND all 3 years of 2017, 2018, and 2019 are also included.
Desired output in the example below is the information on rows 4, 5, and 6.
I have tried the following solution with no success. Is there a quick fix in BASE R?
dat <- data.frame(group = c(0,0,1, 0,0,0, 1, 1, 1),
year = rep(2017:2019, 3))
subset(dat, group == 0 & year == 2017 & year == 2018 & year == 2019)