I am writing a tutorial with learnr and want to include some "other forms of interactivity using Shiny" (from the learnr tutorial). I am new to Shiny but managed -- mainly with copy and paste -- to put to work several examples. Except the following one: (The code is taken from the second part of the video lecture "How to start with Shiny", code example "08-reactiveValues.R")
My YAML header:
output:
learnr::tutorial:
progressive: true
allow_skip: true
runtime: shiny_prerendere
My R chunks:
```{r my-dist-ui, context="render"}
actionButton(inputId = "norm", label = "Normal")
actionButton(inputId = "unif", label = "Uniform")
plotOutput("hist")
```
```{r my-dist-server, context="server"}
rv <- reactiveValues(data = rnorm(100))
observeEvent(input$norm, { rv$data <- rnorm(100) })
observeEvent(input$unif, { rv$data <- runif(100) })
output$hist <- renderPlot({ hist(rv$data) })
```
I can see an empty space reserved for the plot, but no plot. There is no change when I click at the buttons. There is no error message.
Could it be that some of the commands (e.g. reactiveValues or observeEvent) do not work with runtime: shiny_prerendered? (The above example works in its original form in the console. But another example with a plot – the Geyser example – does work in my Learnr Rmd-file.)
I am using R version 3.5.0 with RStudio Version 1.1.453 on a Intel Mac OS X 10_13_5, rmarkdwon 1.10, shiny 1.1.0 and learnr 0.9.2.
content="server"instead ofcontext="server". Once corrected, the plot is showing for me. - user9901566