Reputation: 3294
When I make a Shiny
app in an .Rmd
file to make an isoslides
presentation, the app "behaves" like a static html
page (interactivity is not possible).
For example, the following code in an Rmd
file will produce a static html
presentation that you can not interactively use.
---
output: ioslides_presentation
---
## Useless App
```{r echo=FALSE, message=FALSE, warning=FALSE}
library(shiny)
ui = fluidPage(
numericInput("n", "How old are you?", value = 1)
)
server = function(input, output, session) {
}
shinyApp(ui, server)
What am I missing?
Upvotes: 4
Views: 1057
Reputation: 561
The above answer is inaccurate.
For your YAML header
---
output: ioslides_presentation
runtime: shiny
---
To embed your shiny app (assuming it is a separate file):
```{r, echo = FALSE, message=F, warning=FALSE}
shinyAppFile(
"FileMyAppIsIn/app.R",
options = list(width = "100%", height = 700)
)
``
Upvotes: 2
Reputation: 898
You can't do this unfortunately.
The closest thing would be to deploy your shiny app to some address, either on the web or local, and then embed it in your slides with an iframe.
For example:
---
output: ioslides_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Slide with plot
```{r}
plot(cars)
```
## Slide with Shiny app in iframe
<iframe width = "560" height = "315" src="https://nsgrantham.shinyapps.io/tidytuesdayrocks/"></iframe>
If you wanted to do this with a local app, you would deploy your app in a separate R session, then grab the local address from the browser (e.g. something like: http://111.0.0.1:1234/ and paste that as the iframe source.
Upvotes: 2