I'm very very new to R and am looking at ways of recreating an Excel VBA macro and Excel worksheet functions such as SUMIFS. SUMIFS sums a column if the row has entries matching multiple conditions on its other columns.
I have the below data frame and I want to compute a new column. The new column is the sum of Sample
for all rows that overlap with the Start Date
and EndDate
range. For example on line 1
it would be 697
(the sum of the first 3 lines
). The criteria for the sum specifically: include Sample
if EndDate >= StartDate[i] & StartDate <=EndDate[i]
StartDate EndDate Sample *SUMIFS example*
10/01/14 24/01/14 139 *697*
12/01/14 26/01/14 136
19/01/14 02/02/14 422
25/01/14 08/02/14 762
29/01/14 12/02/14 899
05/02/14 19/02/14 850
07/02/14 21/02/14 602
09/02/14 23/02/14 180
18/02/14 04/03/14 866
Any comments or pointers would be greatly appreciated.