[datatable-help] DT 1.9.5 - refers previous/next/whatever row

Nicolas Paris niparisco at gmail.com
Mon Oct 19 15:59:27 CEST 2015


Hello,

I wonder if there is a way in data.table (or more generaly in R) to work on
previous row without loops
E.G. something equivalent to :

dt <-data.table(col1=c(1,2,3))
for (i in 2:nrow(dt))
{
dt[i,col3:=dt[i-1,list(col1)]>2]
}

Thanks a lot !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20151019/4252f38a/attachment.html>


More information about the datatable-help mailing list