我有这两个表,需要计算totalMilk作为df1 $ date1和df1 $ date2之间dod2的prod之和,其中eartag = eartag。有人请给我一个提示吗?谢谢你提前。何
library(lubridate)
df1 <- data.frame(eartag = 1:10,
date1 = dmy("10/10/16"),
date2 = dmy("10/03/17"),
totalMilk=NA)
df2 <- data.frame(eartag = rep(1:10,each = 10),
edate = rep(dmy("10/10/16") + days(1:10), times = 10),
prod = round(runif(100,0.5,3),1))