R use ddply or aggregate

后端 未结 4 1100
渐次进展
渐次进展 2020-12-01 21:58

I have a data frame with 3 columns: custId, saleDate, DelivDateTime.

> head(events22)
     custId            saleDate      DelivDate
1 280356593 2012-11-1         


        
4条回答
  •  暖寄归人
    2020-12-01 22:21

    This should be pretty fast but data.table is likely faster:

    do.call(rbind, 
        lapply(split(events22, events22$custId), function(x){
            x[which.max(x$saleDate), ]
        })
    )
    

提交回复
热议问题