I have a data frame DF with four fields: id, date, feature, value
. I would like to generate a data frame DF2 with three fields: id, feature, value
, where value
is the value for the corresponding id
and feature
for the latest available date
. In plyr parlance:
DF2 <- ddply(DF, .(id, feature), function(x) c(value(x$value[x$date == max(x$date)]))
I am a bit at a loss on how to achieve this with dplyr using group_by and summarize.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…