I have a data set, for example:
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 summarize the quantitative values when the dates are before May 1, and the aggregated value (amount) should be marked as May 1.
I tried ddply , but it sums all the values regardless of dates.
ddply(se, .(se$Item), summarize, Qty = sum(se$Qty), Value = sum(se$Value))
Also tried a subset by date, without much 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 to add a date argument to code? or how can i do this?
thanks
date r
user3206981
source share