I have a data.table like:
DT = data.table(ColumnA = c(1.51, 1.86, 3.54, 3.79, 7.7))
I am trying to create ColumnB which holds the next value of ColumnA:
columnA ColumnB
1.51 1.86
1.86 3.54
3.54 3.79
3.79 7.70
7.70
I tried the following and it was working, however now it is not working:
``` DT[, ColumnB:=c(NA,ColumnA[.I + 2]) ]```
I am getting this error:
Error in .Call() : Supplied 18391 items to be assigned to 18390 items of column 'ColumnB'. If you wish to 'recycle' the RHS please use rep() to make this intent clear to readers of your code.