I've looked extensively on stack overflow for a solution, but have yet to find one that works for me. I have a data frame that looks something like this:
id time latitude longitude
A 11:10 381746.0 6008345
A 11:11 381726.2 6008294
B 10:56 381703.0 6008214
B 10:57 381679.7 6008134
C 4:30 381654.4 6008083
C 4:31 381629.2 6008033
I would like to insert a new row at the END of each id. In this row, I would like 'id' and 'time' to be the same as the previous observation. I would like latitude and longitude to be '394681.4' and '6017550' (corresponding to the end location of all id's).
id time latitude longitude
A 11:10 381746.0 6008345
A 11:11 381726.2 6008294
A 11:11 394681.4 6017550
B 10:56 381703.0 6008214
B 10:57 381679.7 6008134
B 10:57 394681.4 6017550
C 4:30 381654.4 6008083
C 4:31 381629.2 6008033
C 4:32 394681.4 6017550
Can anyone think of a solution? Dplyr or data table solutions preferred.