Search code examples
ruser-interfaceshinyslideshowslickr

How to use multiple slickROutput in shiny dashboard


I am trying to create a webpage where I have to show multiple slideshows. I found a way of using slickR package in R to display slideshow but i am unable to show multiple. Here is the code where I am trying to render two slickR, I dont know what i am doing wrong.Please help I am just a begginer.

Code:

library(shiny)
library(slickR)

ui <- fluidPage(
     column(12,column(6, slickROutput("slickr", width="200px")),
     column(6,slickROutput("slickr1",width = "200px")))
)

server <- function(input, output) {
  output$slickr <- renderSlickR({
    imgs <- list.files("D:/Projects/Rdashboards/Images/1/", pattern=".png", full.names = TRUE)
    slick <- slickR(imgs)
    slick + settings(autoplay = TRUE,autoplaySpeed = 1000)
  })

  output$slickr1 <- renderSlickR({
    imgs1 <- list.files("D:/Projects/Rdashboards/Images/2/", pattern=".png", full.names = TRUE)
    slick1 <- slickR(imgs1)
    slick1 + settings(autoplay = TRUE,autoplaySpeed = 1000)
  }) 
}

shinyApp(ui = ui, server = server)

Solution

  • You can simply give a different slideID name to each output, like this:

      output$slickr <- renderSlickR({
        imgs <- list.files("D:/Projects/Rdashboards/Images/1/", pattern=".png", full.names = TRUE)
        slick <- slickR(imgs, slideID = "sld1")
        slick + settings(autoplay = TRUE,autoplaySpeed = 1000)
      })
    
      output$slickr1 <- renderSlickR({
        imgs1 <- list.files("D:/Projects/Rdashboards/Images/2/", pattern=".png", full.names = TRUE)
        slick1 <- slickR(imgs1, slideID = "sld2")
        slick1 + settings(autoplay = TRUE,autoplaySpeed = 1000)
      })