0

please see data sample as follows:

3326    2015-03-03  Wm Eu Apple 2L       60
3327    2015-03-03 Tp Euro 2 Layer      420
3328    2015-03-03     Tpe 3-Layer       80
3329    2015-03-03        14/3 Bgs      145
3330    2015-03-04             T/P      196
3331    2015-03-04  Wm Eu Apple 2L    1,260
3332    2015-03-04 Tp Euro 2 Layer      360
3333    2015-03-04        14/3 Bgs    1,355

Currently graphing this data creates a really horrible graph because the amount of cartons change so rapidly by day. It would make more sense to sum the cartons by month so that each data point represents a sum for that month rather than an individual day. The current range of the data is 11/01/2008-04/01/2015.

This is the code that I am using to graph (which may or may not be relevant for this):

ggvis(myfile, ~Shipment.Date, ~ctns) %>%
layer_lines()

Shipment.Date is column 2 in the data set and ctns is the 4th column.

I don't know much about R and have given it a few trys with some code that I have found here but I don't think I have found a problem similar enough to match the code. My idea is to create a new table, sum Act. Ctns for the month and then save it as that new table and graph from there.

Thanks for any assistance! :)

Jaap
  • 81,064
  • 34
  • 182
  • 193
RFC_DA
  • 3
  • 4

1 Answers1

0

Do you need this:

 data.aggregated<-aggregate(list(new.value=data$value), 
                              by=list(date.time=cut(data$date.time, breaks="1 month")), 
                              FUN=function(x) sum(x))
Soheil
  • 954
  • 7
  • 20