Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dum == 1
- times - lead(times) < 30
- mdf <- data.frame(id= c(1,2,2,2,3,3,3,4,4), dum= c(1,0,1,0,0,0,1,1,0), times= c(10,20,20,45,60,70,80,120,170))
- id dum times
- 2 1 20
- library(dplyr)
- mdf1 <- group_by(mdf, id )
- %>%
- filter(dum == 1 , times - lead(times) < 30)
- id dum times
- (dbl) (dbl) (dbl)
- 1 2 1 20
- 2 4 1 120
Add Comment
Please, Sign In to add comment