I have the dataset below with half hourly timeseries data.
Date <- c("2018-01-01 08:00:00", "2018-01-01 08:30:00",
"2018-01-01 08:59:59","2018-01-01 09:29:59")
Volume <- c(195, 188, 345, 123)
Dataset <- data.frame(Date, Volume)
I convert to Date format with:
Dataset$Date <- as.POSIXct(Dataset$Date)
Create xts object
library(xts)
Dataset.xts <- xts(Dataset$Volume, order.by=Dataset$Date)
When I try to decompose it based on this Q with:
attr(Dataset.xts, 'frequency')<- 48
decompose(ts(Dataset.xts, frequency = 48))
I get:
Error in decompose(ts(Dataset.xts, frequency = 48)) :
time series has no or less than 2 periods
as.ts
notts
in the decompose. – phiver