. , data dygraph " ( xts , xts)" (. ?dygraph).
, dfts xts :
> library(xts)
> dfts <- as.xts(dfts)
Error in as.xts.ts(dfts) : could not convert index to appropriate type
xts :
> dfts <- xts(dfts)
Error in xts(dfts) : order.by requires an appropriate time-based object
, xts index(x) order.by. ?xts:
order.by a corresponding vector of unique times/dates -
must be of a known time-based class
...
Currently acceptable classes include: ‘Date’, ‘POSIXct’, ‘timeDate’,
as well as ‘yearmon’ and ‘yearqtr’ where the index values remain unique.
dfts:
> str(index(dfts))
num [1:148] 2012 2012 2012 2012 2012 ...
> head(index(dfts))
[1] 2012.346 2012.365 2012.385 2012.404 2012.423 2012.442
, xts , .
-, all, zoo :
> library(zoo)
>
> p <- predict(hw, 4, prediction.interval=TRUE)
> all <- merge(actual=as.zoo(dfts), predicted=as.zoo(p))
> head(all)
actual fit upr lwr
2012(19) 0.0000000 NA NA NA
2012(20) -0.6264538 NA NA NA
2012(21) -0.4428105 NA NA NA
2012(22) -1.2784391 NA NA NA
2012(23) 0.3168417 NA NA NA
2012(24) 0.6463495 NA NA NA
xts . , date_decimal lubridate:
> library(lubridate)
> all.xts <- xts(all, date_decimal(index(all)))
, dygraph:
> dygraph(all.xts, "time series dygraph") %>%
dySeries("actual", label = "Actual") %>%
dySeries(c("lwr", "fit", "upr"), label = "Predicted")
