8000 swap order of examples so libraries don't clash · plotly/plotly.r-docs@02dbda3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 02dbda3

Browse files
author
Joseph Damiba
committed
swap order of examples so libraries don't clash
1 parent 411c402 commit 02dbda3

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

r/2015-07-30-graphing-multiple-chart-types.Rmd

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,27 @@ fig <- fig %>% layout(xaxis = list(title = 'Displacement (cu.in.)'),
5757
fig
5858
```
5959

60+
### Plotting Forecast Objects
61+
62+
```{r}
63+
library(plotly)
64+
library(forecast)
65+
66+
fit <- ets(USAccDeaths)
67+
fore <- forecast(fit, h = 48, level = c(80, 95))
68+
69+
fig <- plot_ly()
70+
fig <- fig %>% add_lines(x = time(USAccDeaths), y = USAccDeaths,
71+
color = I("black"), name = "observed")
72+
fig <- fig %>% add_ribbons(x = time(fore$mean), ymin = fore$lower[, 2], ymax = fore$upper[, 2],
73+
color = I("gray95"), name = "95% confidence")
74+
fig <- fig %>% add_ribbons(x = time(fore$mean), ymin = fore$lower[, 1], ymax = fore$upper[, 1],
75+
color = I("gray80"), name = "80% confidence")
76+
fig <- fig %>% add_lines(x = time(fore$mean), y = fore$mean, color = I("blue"), name = "prediction")
77+
78+
fig
79+
```
80+
6081
### Loess Smoother with Uncertainty Bounds
6182

6283
```{r}
@@ -83,26 +104,7 @@ fig <- fig %>% layout(xaxis = list(title = 'Displacement (cu.in.)'),
83104
fig
84105
```
85106

86-
### Plotting Forecast Objects
87-
88-
```{r}
89-
library(plotly)
90-
library(forecast)
91-
92-
fit <- ets(USAccDeaths)
93-
fore <- forecast(fit, h = 48, level = c(80, 95))
94-
95-
fig <- plot_ly()
96-
fig <- fig %>% add_lines(x = time(USAccDeaths), y = USAccDeaths,
97-
color = I("black"), name = "observed")
98-
fig <- fig %>% add_ribbons(x = time(fore$mean), ymin = fore$lower[, 2], ymax = fore$upper[, 2],
99- 67BD
color = I("gray95"), name = "95% confidence")
100-
fig <- fig %>% add_ribbons(x = time(fore$mean), ymin = fore$lower[, 1], ymax = fore$upper[, 1],
101-
color = I("gray80"), name = "80% confidence")
102-
fig <- fig %>% add_lines(x = time(fore$mean), y = fore$mean, color = I("blue"), name = "prediction")
103107

104-
fig
105-
```
106108

107109
#Reference
108110

0 commit comments

Comments
 (0)
0