-1

I have data of each hour of approximately 3 years, i am working on how to convert it into time series can u pleas help me out

head(hourly)
  Date...Hour.Block    hour      A1      A2      E1      E2      N1      N2
1        01-01-2015 00 - 01 2000.54 2000.54 2000.54 2000.54 2000.54 2000.54
2                   01 - 02 1849.80 1849.80 1849.80 1849.80 1849.80 1849.80
3                   02 - 03 1699.59 1699.59 1699.59 1699.59 1699.59 1699.59
4                   03 - 04 1699.47 1699.47 1699.47 1699.47 1699.47 1699.47
5                   04 - 05 1699.57 1699.57 1699.57 1699.57 1699.57 1699.57
6                   05 - 06 1764.42 1764.42 1764.42 1764.42 1764.42 1764.42
       N3      S1      S2      W1      W2      W3     MCP
1 2000.54 2000.54 2000.54 1999.27 1999.27 1999.27 1899.85
2  1849.8 1849.80  1849.8 1849.80 1849.80 1849.80 1829.33
3 1699.59 1699.59 1699.59 1699.59 1699.59 1699.59 1699.41
4 1699.47 1699.47 1699.47 1699.47 1699.47 1699.47 1699.31
5 1699.57 1699.57 1699.57 1699.57 1699.57 1699.57 1699.37
6 1764.42 3610.61 3610.61 1764.42 1764.42 1764.42 1779.00

I want to convert only one column data like A1 or MCP

Anil_M
  • 10,893
  • 6
  • 47
  • 74

2 Answers2

0
 library(lubridate)
 dmy_hms("01-01-2015  00:00:00") + hours(1: (24*365*3 + 24*366))
Navin Manaswi
  • 964
  • 7
  • 19
0

2018 answer

You can convert your hourly data(say, train_df) into time series(train_xts) with this line of code:

train_xts <- xts(x = train_df, order.by = train_meta_lj$timestamp)

ts does not work well with hourly time series. It is better to use zoo or xts which is a subclass of zoo. order.by is the column that contains your time observations. Note: the timestamp observation should be in ascending order

Saurabh Jain
  • 1,600
  • 1
  • 20
  • 30