We have external data with daily values (pulled in that format to DB) that need to be added up to approximate monthly values, that align with another external dataset showing approximate monthly values (date range of YYYY-MM-DD in separate columns in that set). The new data forms basis for linear regression.
We would like to use R to:
- Add the daily date values in data1 in the range that meets monthly values of date range in data2. In other words, if "start" in Data2 = 2015-02-14 and "end" in Data2 = 2015-03-15, we want to know the total of daily values of a variable in columnX of data1 for the range 2015-02-14 to 2015-03-15.
can't figure out the logic function to automatically define parameters in Data1 from info in Data2. Is this equation close?
monthly=sum(data1$variable, if(data1$Date > Data2$StartDate & data1$Date < Data2$endDate))
data1$variable is in rows with data1$Date.
The error on the equation above = Error: unexpected ')'
We can not figure out how to build this argument. Any assistance would be appreciated!