2

我正在尝试创建一个网页,我必须在其中显示多个幻灯片。我找到了一种在 R 中使用 slickR 包来显示幻灯片的方法,但我无法显示多个。这是我试图渲染两个 slickR 的代码,我不知道我做错了什么。请帮助我只是一个初学者。

代码:

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)
4

1 回答 1

2

您可以简单地为每个输出指定一个不同的 slideID 名称,如下所示:

  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)
  }) 
于 2020-03-11T09:27:33.050 回答