带data.table的一个组的子集
library(plyr)library(data.table)bdt <- as.data.table(baseball)
ddply(baseball, "id", subset, g == max(g))
setkey(bdt, "id") bdt[g == max(g)] # only one rowbdt[g == max(g), by = id] # Error: 'by' or 'keyby' is supplied but not jbdt[, .SD[g == max(g)]] # only one row
bdt[, .SD[g == max(g)], by = id]
素胚勾勒不出你