Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally evaluate code chunks that use DiagrammeR #603

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions vignettes/get_started.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ if (!file.exists("figures"))

file.copy("../man/figures/plotlegend.png",
"figures/plotlegend.png")

diagrammer_installed <- requireNamespace("DiagrammeR", quietly = TRUE)
```

## Installation
Expand Down Expand Up @@ -384,7 +386,7 @@ greta provides a plot function for greta models to help you visualise and check
```{r plot, eval = FALSE}
plot(m)
```
```{r plot_hidden, echo = FALSE}
```{r plot_hidden, echo = FALSE, eval = diagrammer_installed}
gr <- plot(m)
DiagrammeR::export_graph(attr(gr, "dgr_graph"),
file_name = "figures/full_graph.png",
Expand All @@ -405,7 +407,7 @@ The fourth type of node (diamonds) represents probability distributions. These h

For example, a plot of just the prior distribution over `coef` (defined as `coef <- normal(0, 3)`) shows the parameters as data leading into the normal distribution, and a dashed arrow leading out to the distribution's value, the variable `coef`:

```{r plot_coef, echo = FALSE}
```{r plot_coef, echo = FALSE, eval = diagrammer_installed}
coef <- normal(0, 3)
m_coef <- model(coef)
gr <- plot(m_coef)
Expand All @@ -419,7 +421,7 @@ DiagrammeR::export_graph(attr(gr, "dgr_graph"),

It's the same for the model likelihood, but this time the distribution's parameters are a variable (`sd`) and the result of an operation (`mean`), and the distribution's value is given by data (the observed sepal lengths `y`):

```{r plot_likelihood, echo = FALSE}
```{r plot_likelihood, echo = FALSE, eval = diagrammer_installed}
sd <- variable()
y <- as_data(iris$Sepal.Length)
mean <- ones(150)
Expand Down
Loading