I make group based on the Mac. Again, I make group based on the UNIX_Time.x under the group of Mac. I want to delete a group based on the UNIX_Time.x. if TISD>=254 for one element of the group of UNIX_Time.x , I need to delete the group of UNIX_Time.x. I want to keep other rows of the sameMac. I tried the following code but it deletes the group based on the Mac. could you help me, please?
t %>%
group_by_(.dots = c("Mac", "UNIX_Time.x"))%>%
arrange(Mac, UNIX_Time.x, UNIX_Time.y, TT) %>%
mutate(TISD = (UNIX_Time.y)-lag(UNIX_Time.y))%>%
filter_all(any_vars(is.na(TISD) | TISD<=254)) %>%
ungroup()
Data:
| Mac |
UNIX_Time.x |
UNIX_Time.y |
Location |
TISD |
| A |
1492674854 |
1492682179 |
P1P2 |
200 |
| A |
1492674854 |
1492682203 |
P1P2 |
400 |
| A |
1492699609 |
1492717562 |
P1P2 |
100 |
| A |
1492699609 |
1492717758 |
P1P2 |
196 |
Output:
| Mac |
UNIX_Time.x |
UNIX_Time.y |
Location |
TISD |
| A |
1492699609 |
1492717562 |
P1P2 |
100 |
| A |
1492699609 |
1492717758 |
P1P2 |
196 |