I have one data x with id, date, and details columns:
id date details
1 28-07-2017 20:01:30 NA
2 28-07-2017 18:01:30 NA
1 28-07-2017 22:02:20 SQL
2 28-07-2017 19:01:30 SQL
1 29-07-2017 22:20:00 NA
3 30-07-2017 18:01:30 NA
3 31-07-2017 18:01:30 SQL
4 28-07-2017 18:01:30 NA
I want my data look like this:
id date details
1 28-07-2017 20:01:30 NA
1 28-07-2017 22:02:20 SQL
2 28-07-2017 18:01:30 NA
2 28-07-2017 19:01:30 SQL
3 30-07-2017 18:01:30 NA
3 31-07-2017 18:01:30 SQL
4 28-07-2017 18:01:30 NA
I want to group data x on the basis of id, then sort date in ascending order, then if there is a "SQL" value in the details column then delete the below rows of same id. There should be no records on each id once SQL stage arrives in details variable.
How can I do this in R?