0

I have 2 time series with me. Each Time series is traffic data (# of vehicles passed) for a sensor. However, one time series is hourly and is records traffic data at, say, 1pm, 2pm, 3pm 4pm ...... and so on while the other time series has traffic data recoded at every half an hour, say, 2:15 pm, 2:45 pm, 3:15 pm, 3:45 pm ..... and so on. If I want to merge these 2 series into 1. Does anyone know any framework/package which can do this? Also, what could be the frequency of the resultant? Does it have to be the one with more frequency (i.e. half hourly in this case) so as to lose minimum data?

Any help would be appreciated.

Edit 1: Here's sample example:

Sensor 1:

TimeStamp VehiclesPassed,

1:00 pm 400, 2:00 pm 800, 3:00 pm 900, 4:00 pm 500,

Sensor 2:

TimeStamp VehiclesPassed,

2:15 pm 200, 2:45 pm 300, 3:15 pm 500, 3:45 pm 600

What should the resultant time-series look like? I can not give you output as I am struggling to come u with one which is more acceptable and is standard way of doing in other available frameworks/products.

Thanks (Let me know if I should explain it more.)

  • 1
    When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Mar 07 '18 at 21:23
  • Thanks for suggestion MrFlick. I have edited the question. – Santosh Bobade Mar 07 '18 at 22:29

1 Answers1

1

Define each as a "zoo" series and then use c to combine them:

library(zoo)
library(chron)

ts1 <- zoo(1:4, times(c("13:00:00", "14:00:00", "15:00:00", "16:00:00")))

ts2 <- zoo(11:18, times(c("13:15:00", "13:45:00", "14:15:00", "14:45:00", 
"15:15:00", "15:45:00", "16:15:00", "16:45:00")))

c(ts1, ts2)

giving:

13:00:00 13:15:00 13:45:00 14:00:00 14:15:00 14:45:00 15:00:00 15:15:00 
       1       11       12        2       13       14        3       15 
15:45:00 16:00:00 16:15:00 16:45:00 
      16        4       17       18 
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341