[R] Summarizing data based on Date

Shivi82 shivibhatia at ymail.com
Wed Jun 10 07:51:47 CEST 2015


HI All,

I am able to get the desired result. Thanks for extending help. 
while reading the csv file I made some changes as :

Test<-read.csv("Testdata.csv", head=TRUE, stringsAsFactors = FALSE,
strip.white = TRUE)
with this character var were not changed to factors. 

Then aggregation was simple: 
aggregate(test$CHG_WT, list(test$CR_DT), sum)

However the output is not sorted based on Dates and the columns names
appearing as very different:

Group.1       x
1   1-Mar-15  909791
2  10-Mar-15  822436
3  11-Mar-15  848609
4  12-Mar-15  924842
5  13-Mar-15  895270
6  14-Mar-15  93238
7 2-Mar-15     731600

Can you all please suggest why the column names are so different and how I
could sort based on dates. I added the sort option in the above syntax 
aggregate(test$CHG_WT, list(test$CR_DT), sum,sort(test$CR_DT,decreasing =
TRUE))

But it gave me an error: 
Error in FUN(X[[i]], ...) : invalid 'type' (character) of argument
Thanks All. 




--
View this message in context: http://r.789695.n4.nabble.com/Summarizing-data-based-on-Date-tp4708328p4708423.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list