在R中使用动态图绘制预测
我只是将预测数据复制到不同的数据框中,数据如下所示 数据在R中使用动态图绘制预测,r,dygraphs,R,Dygraphs,我只是将预测数据复制到不同的数据框中,数据如下所示 数据 `Date GMT` Last `Last(Lo).80` `Last(Hi).80` 1 2017-09-23 1650.000 0.000 0.000 2 2017-09-25 1650.000 0.000 0.000 3 2017-09-26 1655.000 0.000 0.000 4 2017-09-27 1653.000
`Date GMT` Last `Last(Lo).80` `Last(Hi).80`
1 2017-09-23 1650.000 0.000 0.000
2 2017-09-25 1650.000 0.000 0.000
3 2017-09-26 1655.000 0.000 0.000
4 2017-09-27 1653.000 0.000 0.000
5 2017-09-28 1652.210 1650.763 1653.657
6 2017-09-29 1652.714 1649.952 1655.477
7 2017-09-30 1653.238 1648.940 1657.536
8 2017-10-01 1654.264 1648.251 1660.278
代码
s <-subset(d1, select = c(1,5,6,7))
dygraph(s, main ="Price chart") %>%
dyRangeSelector() %>%
dyRangeSelector(height = 40,
dateWindow = c("2017-09-23", "2017-10-01")) %>%
dySeries(name = "actuals", label = "actual") %>%
dySeries(c(2,3,4), label = "Predicted") %>%
dyLegend(show = "always", hideOnMouseOut = FALSE) %>%
dyHighlight(highlightCircleSize = 5,
highlightSeriesOpts = list(strokeWidth = 2)) %>%
dyOptions(axisLineColor = "navy", gridLineColor = "grey")
s%
dyRangeSelector()%>%
动态范围选择器(高度=40,
日期窗口=c(“2017-09-23”、“2017-10-01”)%>%
dySeries(name=“actuals”,label=“actual”)%%>%
dySeries(c(2,3,4),label=“Predicted”)%>%
动态图例(show=“始终”,hideOnMouseOut=FALSE)%>%
动态高光(highlightCircleSize=5,
highlightSeriesOpts=list(行程宽度=2))%>%
动态选项(axisLineColor=“海军”,gridLineColor=“灰色”)
运行此程序时,我收到不受支持的数据错误将数据作为时间序列对象输入到动态图中
d1 <- read.table(text="
'Date GMT' 'Last' 'Last(Lo).80' 'Last(Hi).80'
1 2017-09-23 1650.000 0.000 0.000
2 2017-09-25 1650.000 0.000 0.000
3 2017-09-26 1655.000 0.000 0.000
4 2017-09-27 1653.000 0.000 0.000
5 2017-09-28 1652.210 1650.763 1653.657
6 2017-09-29 1652.714 1649.952 1655.477
7 2017-09-30 1653.238 1648.940 1657.536
8 2017-10-01 1654.264 1648.251 1660.278
", header=T)
d1$Date.GMT <- as.POSIXct(d1$Date.GMT, format = "%Y-%m-%d", tz="GMT")
library(tseries)
ts1 <- irts(time=d1[,1], value=as.matrix(d1[,2:4]))
library(dygraphs)
dygraph(ts1, main ="Price chart") %>%
dyRangeSelector() %>%
dyRangeSelector(height = 40,
dateWindow = c("2017-09-23", "2017-10-01")) %>%
dyLegend(show = "always", hideOnMouseOut = FALSE) %>%
dyHighlight(highlightCircleSize = 5,
highlightSeriesOpts = list(strokeWidth = 2)) %>%
dyOptions(axisLineColor = "navy", gridLineColor = "grey")
d1%
动态图例(show=“始终”,hideOnMouseOut=FALSE)%>%
动态高光(highlightCircleSize=5,
highlightSeriesOpts=list(行程宽度=2))%>%
动态选项(axisLineColor=“海军”,gridLineColor=“灰色”)