I have the following R code. Essentially, I am asking R to arrange the dataset based on postcode and paon, then group them by id, and finally keep only the last row within each group. However, R requires more than 3 hours to do this.
I am not sure what I am doing wrong with my code since there is no for loop here.
epc2 is a vector with 324,368 rows.
epc3 <- epc2 %>%
  arrange(postcode, paon) %>% 
  group_by(id) %>% 
  do(tail(., 1)) 
Thank you for any and all of your help.
 
     
    