【发布时间】:2018-07-04 09:31:48
【问题描述】:
我对最新的 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)
})})})
}
)
【问题讨论】:
-
听起来像是 DT 的 bug。我现在正在调查它。谢谢!