I have a data set like following:
Date Country Item Qty Value
15-04-2014 SE 08888 2 20
28-04-2014 SE 08888 2 20
05-05-2014 SE 08888 6 80
I want to sum quantity values when the dates are before the 1 May, and the aggregated value (the sum) should be marked as 1 May.
I tried ddply
, but it sums all the value regardless of the dates.
ddply(se, .(se$Item), summarize, Qty = sum(se$Qty), Value = sum(se$Value))
Also tried subsetting by the date, with no big success.
se$Date <- as.Date(as.character(se$Date))
se_q <- subset(se,se$Date <= 01-05-2014)
Date Country Item Qty Value
0015-04-20 SE 08888 2 20
0028-04-20 SE 08888 2 20
0005-05-20 SE 08888 6 80
How could I add the date argument in the code? or how could I do this?
Thank you