I am enjoying using the learnr and grader packages for R. I have managed to incorporate some shiny elements, very nice!
However, i would like to include exercises where learners can write, check and submit answers for shiny based questions. However, the run code function in an exercise doesn't do anything (i get shiny window saying Shiny app not supported in static R Markdown documents), so i'm assuming it will not work or i have missed something?
this is a sample of the exercise code;
title: "Programming basics"
output:
learnr::tutorial:
progressive: true
allow_skip: true
runtime: shiny_prerendered
```{r ex_shiny_1, exercise=TRUE}
library(shiny)
ui <- fluidPage(
titlePanel("My First App"),
sidebarLayout(
sidebarPanel("inputs will go here"),
mainPanel("outputs will go here")
)
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
I know i can uses quizes within learnr, but i would really like the users to see their shiny code running without having to move from the tutorial to RStudio IDE.
Ive managed to include shiny elements in the tutorial using something similar to and work really well;
sliderInput("bins", "Number of bins:", 30, min = 1, max = 50)
plotOutput("distPlot")
output$distPlot = renderPlot({
x = faithful[, 2] # Old Faithful Geyser data
bins = seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
Thanks in advance!