【问题标题】:why R Shiny Loading Spinner from shinycssloaders is not showing up为什么来自 shinycssloaders 的 R Shiny Loading Spinner 没有出现
【发布时间】:2020-04-25 08:26:57
【问题描述】:

我正在尝试在我的表格输出中添加一个加载微调器。但是当我使用表的列名来更新复选框组输入的选择时,微调器消失了。这是问题的一个示例。

有没有办法解决这个问题,或者有没有其他加载图标选项?

library(shiny)
library(shinycssloaders)
data(mtcars)

ui <- fluidPage(
  actionButton(inputId = 'a', label = 'show dataset'),
  checkboxGroupInput(inputId = 'b', label = 'Select Column'),
  tableOutput('table')%>% withSpinner(),
)

server <- function(input, output, session) {
  data = eventReactive(input$a, {
    # Pause for 3 seconds to simulate a long computation.
    Sys.sleep(3)
    mtcars
  })

  # loading spin disappear afer I add updateCheckboxGroupInput based on the output data column names 
  observeEvent(input$a, {updateCheckboxGroupInput(session, 'b', choices = colnames(data()))})

  # if updateCheckboxGroupInput does not depend on output data, loading spin will show up
  #observeEvent(input$a, {updateCheckboxGroupInput(session, 'b', choices = c('a','b','c'))})

  output$table = renderTable({data()})

}

shinyApp(ui = ui, server = server)

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    你在这一行多了一个逗号: tableOutput('table')%&gt;% withSpinner(),

    万一其他人看到这个,这个例子也使用了管道,即%&gt;%,但没有添加它们的包。您可以切换到withSpinner(tableOutput('table')) 或包含library(magrittr)

    【讨论】:

      猜你喜欢
      • 2021-09-01
      • 1970-01-01
      • 2015-08-29
      • 2022-12-11
      • 2019-07-24
      • 2023-02-22
      • 1970-01-01
      • 1970-01-01
      • 2016-06-28
      相关资源
      最近更新 更多