I learned from this question that you can set shinyApp options to showcase mode
in order to visualize (i.e., highlight) which parts of your Shiny code are executing as a user interacts with your application.
However, when I try to apply this to an interactive Shiny doc using knitr/R markdown, the showcased code fails to show up.
How can I make showcase mode
work in an interactive doc?
Example:
---
title: "Showcase Mode Doesn't Work in knitr"
output: html_document
runtime: shiny
---
See, look, no highlatable code shows up with the app:
```{r, echo=FALSE}
library(shiny)
ui <- fluidPage(
textInput(inputId = 'textin', label = ''),
textOutput(outputId = 'textout')
)
server <- function(input, output){
output$textout <- renderText({input$textin})
}
shinyApp(ui = ui, server = server, options = list(display.mode='showcase'))
```
The reason that you can't specify the showcase mode
for a markdown
document is simple - it doesn't exist.
Knitr
(and Rmarkdown
documents) is pre-rendering the output outcomes in an html
page. In the case of the interactive html
documents, it pre-renders all of the outputs for your "rendered object" and switches between them as specified by the input (if I understood the explanation given by Yihui Xie at Rconf this year).
Whereas in shiny
, the output is generated dynamically because there is a backend (your computer, the server etc.) which is running the code new when the inputs are changed. That's why you can turn on showcase
and see those things changing and being re-run dynamically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With