I have data in an hourly values.
SNo Date Hour X
1 2006-12-17 00:00:00 1.8824667
2 2006-12-17 01:00:00 3.3494000
3 2006-12-17 02:00:00 1.5872667
4 2006-12-17 03:00:00 1.6622000
5 2006-12-17 04:00:00 2.2157667
6 2006-12-17 05:00:00 1.9967333
7 2006-12-17 06:00:00 1.3033000
8 2006-12-17 07:00:00 1.6200333
9 2006-12-17 08:00:00 1.8905667
10 2006-12-17 09:00:00 2.5490667
11 2006-12-17 10:00:00 3.6289000
How would I create a time series out of this? What would be the frequency and start/end parameters?
The last date & time is
2010-11-26 21:00:00
Here's how to use the ts()
function in base R
(assuming your data X
are contained in the data frame dat
). You'll need to specify the first year and hour for start
(you don't need end
), and frequency
will be the number of hours in a year.
firstHour <- 24*(as.Date("2006-12-17 00:00:00")-as.Date("2006-1-1 00:00:00"))
tt <- ts(dat$X,start=c(2006,firstHour),frequency=24*365)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With