Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

How to convert data in "Practice Problem: Time Series" to ts format in R?

$
0
0

@Pranov_Mishra wrote:

Hi all,

I am working on the dataset (in the practice problem in AV) which has hourly values over a period of 2 years. I had difficulty in converting the data to timeseries format.since the frequency is required to be very different with hourly information. it cant be 12, 4 or 1 for monthly, quaterly or annually. I tried using frequency as below

frequency = 247365.25

So i used xts package to get it to a format with rownames as date+time and values as a column. The data is now in xts class and i am guessing i cant use the ts functions like plot, decompose etc to proceed.

The plot function does not show the trending for full time period. The decompose function does not work.

If someone can tell me how to convert this data to ts format i think I can proceed with what is required. Appreciate your help. A snapshot of the data is below

ID Datetime Count
1 0 2012-08-25 00:00:00 8
2 1 2012-08-25 01:00:00 2
3 2 2012-08-25 02:00:00 6
4 3 2012-08-25 03:00:00 2
5 4 2012-08-25 04:00:00 2
6 5 2012-08-25 05:00:00 2

My code at this point is as below and i would delighted if somebody can help me proceed to do timeseries forecasting on this dataset.

TS.train=read.csv(“Train.csv”)

TS.train$Datetime=as.POSIXct(strptime(TS.train$Datetime,format = “%d-%m-%Y %H:%M”))
library(xts)
train=xts(x=TS.train[,-c(1,2)], order.by = TS.train[,2])
names(train)=“Values”
summary(train$Values)
train.ts=ts(train$Values,start = c(2012,8), frequency = 247365.25)

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles