r - Deleting specific columns based on conditions -
i have dataset in r column indicating errors on task: 0 = no error. 1 = error.
how delete rows error column shows 1 (for error) , subsequent row (even if 0) ?
example:
id part block response time wrong 1 1 1 1 307 2015-04-26 0 2 2 1 1 291 2015-05-03 1 3 3 1 1 310 2015-05-10 0
how delete rows 2 , 3?
cheers!
you do:
library(dplyr) df %>% filter(!(wrong == 1 | lag(wrong == 1, default = f)))
Comments
Post a Comment