lets say I have a df as
ID <- c("A1","A1","A1", "A2","A2","A3", "A3", "A3")
b <- c(1,2 , 3, 1, 2, 1, 2, 3)
c <- c (100, 200, 300 ,400, 500 ,600 ,700, 800 )
df1 <- data.frame(ID,b,c)
SO the df looks like that
a b c
1 A1 1 100
2 A1 2 200
3 A1 3 300
4 A2 1 400
5 A2 2 500
6 A3 1 600
7 A3 2 700
8 A3 3 800
I want to move the value of c, within ID, to the next row in a new column
so the result should be like
a b c new
1 A1 1 100 NA
2 A1 2 200 100
3 A1 3 300 200
4 A2 1 400 NA
5 A2 2 500 400
6 A3 1 600 NA
7 A3 2 700 600
8 A3 3 800 700