Reputation: 13
I have a data frame with dates going from 2012-04-18 00:00:00
to 2012-04-30 23:00:00
.
I want to convert it to a time series using the ts
function but I can't manage to configure it.
I have tried:
newdata <- ts(data[-1], start = as.Date("2012-04-18"), freq = 312)
but it doesn't seem to work.
Upvotes: 0
Views: 191
Reputation: 11981
the syntax for the ts
function is a little different.
As it is written on the help page of ts
:
start: the time of the first observation. Either a single number or a vector of two integers, which specify a natural time unit and a (1-based) number of samples into the time unit. See the examples for the use of the second form.
Try this:
newdata <- ts(data[-1], start = c(2012, 4.5), freq = 312).
However when working with intraday data I would rather recommend the xts
package and work with xts
objects instead on ts
objects.
Upvotes: 1