DT版本0.3(最新)不渲染表

时间:2018-01-25 07:30:38

标签: r shiny dt

我对最新的DT版本(0.3)有疑问。从DT版本0.2.20更新到0.3后,按下actionButton后的表格没有呈现,没有给出任何错误。更改我的代码并实现eventReactive后,将呈现一个表。但是,我只是好奇发生新版本的DT(0.3)与我的旧方法或isolate不能很好地发生了什么?

以下是准确显示此问题的代码:

library(shiny)
library(DT)
shinyApp(
  ui = fluidPage(radioButtons("buttons","", choices = c("iris","mtcars")),
                 actionButton("button1", "Choose"),
                 DT::dataTableOutput('tbl'),
                 DT::dataTableOutput('tbl2')),
  server = function(input, output) {

    #1st possibility with eventReactive WORKING WITH THE NEW DT VERSION (0.3)


    data <- eventReactive(input$button1,
                          {if(input$buttons  == "mtcars"){mtcars}else{
                            iris}
                          })

    output$tbl = DT::renderDataTable({
      datatable(data())}
    )

    #2nd possibility with isolate WHICH IS NOT WORKING WITH DT = 0.3 BUT IT IS WORKING WITH DT = 0.2.20!! 

    output$tbl2 <- renderDataTable ({
      withProgress(message = 'Processing...', style = "old",value = 0, 
                   {

                     for (i in 1:10) {
                       incProgress(1/30)
                       Sys.sleep(0.1)
                     }
                     if( input$button1 == 0)
                     {
                       return()
                     }
                     isolate({
                       data <- if(input$buttons  == "mtcars"){mtcars}else{
                         iris}
                       datatable(data)
                     })})})


  }
)

1 个答案:

答案 0 :(得分:1)

这是由于 DT 0.3(已在#488#489中报告)中的错误,我昨天有fixed it。目前,请尝试 DT 的开发版本:

devtools::install_github('rstudio/DT')