Summing a dataframe based on another dataframe
问题 I have daily data of rainfall from 10 locations across 10 years set.seed(123) df <- data.frame(loc.id = rep(1:10, each = 10*365),years = rep(rep(2001:2010,each = 365),times = 10), day = rep(rep(1:365,times = 10),times = 10), rain = runif(min = 0 , max = 35, 10*10*365)) I have a separate data frame that has certain days using which I want to sum the rainfall in df df.ref <- data.frame(loc.id = rep(1:10, each = 10), years = rep(2001:2010,times = 10), index1 = rep(250,times = 10*10), index2 =