Hi everyone I found something similar to what I need to do but it doesn't work with my full data
How to remove rows after a particular observation is seen for the first time
What I need to do is to delete every observation after the client reach 4 in the Variable state, the answer in the previous link give the solution for only one client.
The data Problem
If anyone needs the data:
structure(list(mes = structure(c(2016, 2016.08333333333,2016.16666666667,2016.25, 2016.33333333333, 2016.41666666667,2016.5, 2016.58333333333,2016.66666666667, 2016.75, 2016.83333333333, 2016.91666666667,2016, 2016.08333333333, 2016.16666666667, 2016.25, 2016.33333333333, 2016.41666666667, 2016.5, 2016.58333333333, 2016.66666666667,2016.75, 2016.83333333333, 2016.91666666667), class = "yearmon"),inicio = structure(c(2002.25, 2002.25, 2002.25, 2002.25,
2002.25, 2002.25, 2002.25, 2002.25, 2002.25, 2002.25, 2002.25,
2002.25, 2004.41666666667, 2004.41666666667, 2004.41666666667,
2004.41666666667, 2004.41666666667, 2004.41666666667, 2004.41666666667,
2004.41666666667, 2004.41666666667, 2004.41666666667, 2004.41666666667,
2004.41666666667), class = "yearmon"), diff = c(13.75, 13.8333333333333,
13.9166666666667, 14, 14.0833333333333, 14.1666666666667,
14.25, 14.3333333333333, 14.4166666666667, 14.5, 14.5833333333333,
14.6666666666667, 11.5833333333333, 11.6666666666665, 11.75,
11.8333333333333, 11.9166666666665, 12, 12.0833333333333,
12.1666666666665, 12.25, 12.3333333333333, 12.4166666666665,
12.5), code = c("0000040542281157798", "0000040542281157798",
"0000040542281157798", "0000040542281157798", "0000040542281157798",
"0000040542281157798", "0000040542281157798", "0000040542281157798",
"0000040542281157798", "0000040542281157798", "0000040542281157798",
"0000040542281157798", "00000803019311630270", "00000803019311630270",
"00000803019311630270", "00000803019311630270", "00000803019311630270",
"00000803019311630270", "00000803019311630270", "00000803019311630270",
"00000803019311630270", "00000803019311630270", "00000803019311630270",
"00000803019311630270"), state = c(1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4)), .Names = c("mes","inicio", "diff","code", "state"), row.names = c(NA,24L), class = "data.frame")
Thanks for your help