Remove observations from a panel data for which data is not available from both pre and post treatment period

Viewed 34

I have a panel data frame like this:

test <- data.frame(id = c("A", "A", "A", "B", "B"), year = c("2014", "2015", "2016", "2014", "2015"), income = c("100", "150", "200", "300", "200"))

Suppose 2015 is when the "treatment" took place.

Now, I would like to keep only those observations from which data are available both before and after 2015. In other words, my expected data frame will exclude all B's. Any input would be highly appreciated. Thanks.

0 Answers
Related