Skip to content
Prev 302926 / 398503 Next

POSIXct to ts

On Thu, Aug 9, 2012 at 3:30 PM, Mary Ann Middleton <maberg at sfu.ca> wrote:
Thank you for the dput()-ed data!

The "time series" object that stl() and decompose() expect doesn't
have time stamps -- rather it has a "start" and "end" marker as well
as a frequency. [For more details, see ?tsp]

With your described data, I'd imagine you'd have start = 2008 and
frequency = 365*24 (if you have hourly data and an underlying yearly
periodicity) but to work with the data you gave, lets suppose 12 hours
is a cycle. Note you don't have to give end because that's figured out
automatically from frequency and start.

x.ts <- ts(x[,2], start = 1, frequency = 12)

then I can

stl(x, "per")
decompose(x)

as desired.

Hope that helps,
Michael