Reputation: 11
I am trying to develop my class lecture slides using Shiny apps and ioslides. I would like to have several Shiny apps, each on a different slide to illustrate different concepts. When I naively write the input and render code for an app on a slide, only the first app works and the succeeding apps do not work.
Do I have to shut down the first app before starting the second (and so forth)? I can't seem to find an answer anywhere and I hope someone here can lead me in the right direction. Thanks, in advance.
Upvotes: 1
Views: 400
Reputation: 3152
I had the same problem recently and what you have to avoid its to think you are making differente shiny app in the same presentation, because the hole documen its a shiny runtime. Here you do not have to create explicitly the objects "ui" and "serve"
Look at this example to see if you can get the idea
---
title: "Shiny app - stackoverflow help"
author: "Johan Rosa"
date: "August 8, 2018"
output: ioslides_presentation
runtime: shiny
---
## first slide
```{r}
fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
```
```{r}
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
```
## next slide
#The other app you want toy show, just the way i did it in the first slide
Upvotes: 0