Skip to content

Commit 8984cee

Browse files
committed
πŸ“ Move interactive vignette to inst
The build vignette is too large.
1 parent 49e7b18 commit 8984cee

5 files changed

Lines changed: 31 additions & 4 deletions

File tree

β€Ž.Rbuildignoreβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
^codecov\.yml$
1414
^data-raw$
1515
^docs$
16+
^inst/*\.html$
1617
^man-roxygen$
1718
^organisation.yml$
1819
^pkgdown$

β€Ž_pkgdown.ymlβ€Ž

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ navbar:
2727
href: articles/classification.html
2828
- text: Visualising Effects with `ggplot2`
2929
href: articles/visualisation.html
30-
- text: Visualising Effects with `plotly`
31-
href: articles/interactive.html
3230
reference:
3331
- title: Classification of Effects
3432
contents:
Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ vignette: >
1111

1212
```{r setup, include = FALSE}
1313
library(knitr)
14-
opts_chunk$set(collapse = TRUE, comment = "#>")
14+
opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 6)
1515
inbo_colours <- c("#282A72", "#EF972C")
1616
```
1717

@@ -144,6 +144,31 @@ plot_ly(timeserie, x = ~year, y = ~index) |>
144144
add_vert_norm(sd = ~s, link = "log")
145145
```
146146

147+
## `add_classifiction()`
148+
149+
```{r add-classification}
150+
z <- data.frame(
151+
estimate = c(-0.5, 0, 0.5, 1.5, 1, 0.5, 0, -0.5, -1, -1.5),
152+
sd = c(rep(0.8, 3), rep(0.3, 7))
153+
)
154+
z$lcl <- qnorm(0.05, z$estimate, z$sd)
155+
z$ucl <- qnorm(0.95, z$estimate, z$sd)
156+
classification(z$lcl, z$ucl, threshold = 1) -> z$effect
157+
z$x <- class_labels(type = "effect")[z$effect]
158+
z$x <- factor(z$x, z$x)
159+
z$display <- paste(
160+
"estimate:", format_ci(z$estimate, lcl = z$lcl, ucl = z$ucl)
161+
)
162+
plot_ly(z, x = ~x, y = ~estimate) |>
163+
add_fan(sd = ~sd, text = ~display) |>
164+
add_classification(lcl = ~lcl, ucl = ~ucl, threshold = 1) |>
165+
layout(
166+
hovermode = "x unified",
167+
shapes = reference_shape(threshold = 1),
168+
annotations = reference_text(threshold = 1)
169+
)
170+
```
171+
147172
## Reference
148173

149174
The `reference_shape()` and `reference_text()` functions can be used to add a reference lines and text to the plot.

β€Žvignettes/visualisation.Rmdβ€Ž

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Visualising Effects with `ggplot2`"
33
author: Thierry Onkelinx
4-
bibliography: references.bib
4+
bibliography: '`r system.file("references.bib", package = "effectclass")`'
55
output: rmarkdown::html_vignette
66
vignette: >
77
%\VignetteIndexEntry{Visualising Effects with `ggplot2`}
@@ -137,6 +137,9 @@ The `vignette("classification", package = "effectclass")` explains how we can cl
137137
This vignette focusses on visualising effect and their uncertainty.
138138
The packages provides two `ggplot()` layers (`stat_fan()` and `stat_effect()`) and a scale (`scale_effect()`).
139139

140+
Note that this package also supports `plotly`.
141+
Run `rmarkdown::render(system.file("interactive.Rmd", package = "effectclass"))` to generate this document.
142+
140143
## `stat_fan()`
141144

142145
The Bank of England visualises uncertainty by using a fan plot [@britton.fisher.ea1998InflationReportProjections].

0 commit comments

Comments
Β (0)