Samoth
Samoth

Reputation: 756

r shiny data table sometimes does not display

I encountered a weird situation that made me confused and searched for a while but seems no same issues as mine with data table package.

I simply used the basic default data table in my shiny app, see example:

Server.R

 library(shiny)
 library(DT)
 shinyServer(function(input, output) {

 output$expense_table_check<-renderDataTable({
   iris
 })
})

ui.R

library(shiny)
shinyUI(fluidPage(
mainPanel(
      navlistPanel(
       tabPanel("DT",h1("DT"),
       dataTableOutput("expense_table_check"))
   )
  )
 ) 
)

Sometimes the above works fine but sometimes not. I tried replacing dataTableOutput("expense_table_check") with dataTableOutput('expense_table_check') and then it works sometimes, but sometime not.

I also tried replacing the output name expense_table_check with expense_table_check2. But still cannot solve the issue. Any suggestion or comment is appreciated.

Upvotes: 4

Views: 3557

Answers (1)

Samoth
Samoth

Reputation: 756

I finally solved the issues after revising the code as following and now it works well all the time; just add DT:: in front of datatable:

Server.R

 library(shiny)
 library(DT)
 shinyServer(function(input, output) {

 output$expense_table_check <- DT::renderDataTable({
   iris
 })
})

ui.R

library(shiny)
shinyUI(fluidPage(
mainPanel(
      navlistPanel(
       tabPanel("DT",h1("DT"),
       DT::dataTableOutput("expense_table_check"))
   )
  )
 ) 
)

Upvotes: 3

Related Questions