我对最新的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)
})})})
}
)