Using cut
and plyr::ddply
:
groups <- cut(as.POSIXct(df$datetime), breaks="2 min")
library(plyr)
ddply(df, "groups", tail, 1)[, -1]
# date time datetime use..kW. gen..kW. Grid..kW.
# 1 12/31/2013 21:50 2013-12-31 21:50:00 2.096550 -0.003850000 2.096550
# 2 12/31/2013 21:52 2013-12-31 21:52:00 2.011867 -0.003583333 2.011867
# 3 12/31/2013 21:54 2013-12-31 21:54:00 2.008283 -0.003566667 2.008283
# 4 12/31/2013 21:56 2013-12-31 21:56:00 2.494750 -0.003350000 2.494750
# 5 12/31/2013 21:58 2013-12-31 21:58:00 1.829583 -0.003400000 1.829583
Or
arrange(ddply(df, "groups", tail, 1)[, -1], datetime, decreasing=TRUE)
if you want to sort it the other way round.