I'm fairly new in R. I have a database (panel) and I want to delete some observations based on certain values. Let's take the next panel as an example (derived from plm packages):
Panel <-read.dta("http://dss.princeton.edu/training/Panel101.dta")
> head(Panel)
country year y y_bin x1 x2 x3 opinion op
1 A 1990 1342787840 1 0.2779036 -1.1079559 0.28255358 Str agree 1
2 A 1991 -1899660544 0 0.3206847 -0.9487200 0.49253848 Disag 0
3 A 1992 -11234363 0 0.3634657 -0.7894840 0.70252335 Disag 0
4 A 1993 2645775360 1 0.2461440 -0.8855330 -0.09439092 Disag 0
5 A 1994 3008334848 1 0.4246230 -0.7297683 0.94613063 Disag 0
6 A 1995 3229574144 1 0.4772141 -0.7232460 1.02968037 Str agree 1
I want to delete the observations for the next year when OP=1. For instance if in 1990, OP =1, I want to exclude country in 1991, 1992, 1992, etc (all the next years of the database). If OP =1 in 1996, I want to exclude country in 1997, 1998 and 1999.
PS : The dataframe may be not be a good example but in my dataframe, OP = 1 only once.
Does anyone know how I can do that?
Thanks in advance.
EDIT : I forgot to say that I want also to keep observations that have OP=0 for each year. I'm running a logit model. Therefore I'm comparing OP=1 and OP=0.