简体   繁体   中英

How to set and display index with multiple columns using R time series and forecast

I have a sample usage table of 'Account','Asset','Date','Asset Network Usage' with 15 days of summarised Usage data per Asset. I am trying to append the table with forecasted usage per day over the next 15 days, or at least create an output with the same table structure.

Eg

Date (m/d/Y)     Account         Asset  Network Usage
4/4/2019    Acct#100        AS-4310 56.5251
4/5/2019    Acct#100        AS-4310 592.1843
4/6/2019    Acct#100        AS-4310 556.1898
4/7/2019    Acct#100        AS-4310 808.2403
4/8/2019    Acct#100        AS-4310 466.118

I've been able to produce the appended table aggregating only by Date. I want to include Date / Account / Asset however I'm challenged in setting an index that doesn't run into an error on the timeseries ts() function

library(forecast)
library(ggfortify)

dataset <- 
as.data.frame(read.csv(file="/path/Data.csv",header=TRUE,sep=","))

dataset <- aggregate(Network_Usgae ~ Date,data = dataset, FUN= sum)

ts <- ts(dataset$Network_Usage, frequency=15)

decom <- stl(ts,s.window = "periodic")

pred <- forecast(decom,h = 15)

fort <- fortify(pred,ts.connect= TRUE )

Any suggestions on syntax updates, or use of a different method to achieve my outcome?

I think forecast only works on objects convertable to matrixes, my suggestion is using lists and predicting the "values" while keeping relevant information about other stuff in other elements.

If you provide a dput() dataset I can create an example for you.

Good Luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM