I have a data frame df like below:
id country_id
__ _______
1 01
1 02
1 03
2 01
2 04
2 05
3 06
3 08
3 09
3 10
This shows how each person travelled to which country.From this I need to have something like this
id from to
___ _____ ____
1 01 02
1 02 03
1 03 NA
2 01 04
2 04 05
2 05 06
3 06 NA
3 08 09
3 09 10
3 10 NA
I can make df[-1] which gives the whole vector without top and then cbind it But then how to make NA at each id's last entry? Any help is appreciated .