In dplyr package, I am using group_by() function and then applying the filter() function to remove some rows from that group. Now, I want to put the removed rows (which are left out from the group) into a whole new group.
This is my code-
threshold <- dummy %>%
group_by(expiry_date, location_code,model,age,Emp_id) %>%
filter(Date <= as.Date(min(Date) + 2), .preserve = TRUE) %>
It is giving me the filtered out rows but I want to keep the removed rows as well in a different group. Please provide me a work around for this. Thank You!