I have a data frame "gg", that looks like this:
> head(gg)
timestamps value
1 2017-04-25 16:52:00 -0.4120000
2 2017-04-25 16:53:00 -0.4526667
3 2017-04-25 16:54:00 -0.4586667
4 2017-04-25 16:55:00 -0.4606667
5 2017-04-25 16:56:00 -0.5053333
6 2017-04-25 16:57:00 -0.5066667
I need to plot this as a Time series data to do forecasting. The steps are as follows:
1) gg$timestamps <- as.POSIXct(gg$timestamps, format = "%Y-%m-%d %H-%M-%S") #changing "Timestamps" column 'factor' to 'as.POSIXct'.
2) gg.ts <- xts(x=gg$value, order.by = gg$timestamps) #converting the dataframe to time series (Non Regular Time series)
Now i want this gg.ts
converted to regular time series to do forecasting like this (Forecasting time series data)
But i don't know how to add the timestamp values series to ts
function. When i tried it throws error :
> gg.xts <- ts(gg.ts, frequency = '1', start = c(2017-04-25 16:52:00,171))
Error: unexpected numeric constant in "gg.xts <- ts(gg.ts, frequency = '1', start = c(2017-04-25 16"
I have my whole problem listed clearly here. https://stackoverflow.com/questions/43627826/plotting-time-series-data-r-plotly-timestamp-values please help me. Thanks