I have word frequencies observed in a data corpus in a single day, across 10minutes time interval. The data looks something like this:
word 00:00:00 00:11:00 00:22:00 00:33:00 . . . . 23:17:00 23:28:00 23:39:00
Robert 10 20 22 32 . . . . 10 11 10
Harvey 12 35 12 12 . . . . 15 26 9
I want to generate a time series object for this data using R. I know that the ts() function can be used to generate time series object where I can specify the start year and the time-interval being months or quarters. Example:
ts(data, frequency=12, start=c(1946,1))
But, I don't know how can I use ts() to specify that data has been collected over 10minutes time intervals in a single day. Any clue?
Also, as you can see my data has time information in the header. Can that be used to generate time series object in R?
Briefly, your main options are
Use ts()
, but read the help page and figure out that you can use frequency=
or deltat=
. As your data frequency is in fact regular, you could could try something like deltat=24*60/11
. [ And looking at your data, it seems to be 11 minutes rather than 10 as your question title suggests. ] ts()
is useful if you want to fit ARIMA-class models.
Use the zoo package and its zooreg
class and see the documentation in the package vignettes. I find zoo to be more easy to work with.