Datatable not rendering mixed datatypes correctly

I have used DT in the past with good success. Today, I am getting the error below:

This results in the iris dataframe displayed as below:

I observed similar error with my dataframe, but not with mtcars . I am guessing the issue could be that mtcars has all ints.

Following is a reproducible example:

#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
#    http://shiny.rstudio.com/
#

library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(
   
   # Application title
   titlePanel(""),
   
   # Sidebar with a slider input for number of bins 
   sidebarLayout(
      sidebarPanel(

      ),
      
      # Show a plot of the generated distribution
      mainPanel(
         dataTableOutput("reports_table")
      )
   )
)

# Define server logic required to draw a histogram
server <- function(input, output) {
   
   output$reports_table <- renderDataTable({
     iris
   })
}

# Run the application 
shinyApp(ui = ui, server = server)

This was used to generate the second image. sessionInfo as below:

R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363), RStudio 1.2.5033

Locale:
  LC_COLLATE=English_United States.1252 
  LC_CTYPE=English_United States.1252   
  LC_MONETARY=English_United States.1252
  LC_NUMERIC=C                          
  LC_TIME=English_United States.1252    

Package version:
  askpass_1.1       BH_1.72.0.3       compiler_3.6.3   
  crayon_1.3.4      crosstalk_1.1.0.1 curl_4.3         
  digest_0.6.25     DT_0.13.2         fastmap_1.0.1    
  graphics_3.6.3    grDevices_3.6.3   htmltools_0.4.0  
  htmlwidgets_1.5.1 httpuv_1.5.2      jsonlite_1.6.1   
  later_1.0.0       lazyeval_0.2.2    magrittr_1.5     
  methods_3.6.3     mime_0.9          openssl_1.4.1    
  packrat_0.5.0     promises_1.1.0    R6_2.4.1         
  Rcpp_1.0.4.6      rlang_0.4.5       rsconnect_0.8.16 
  rstudioapi_0.11   shiny_1.4.0.2     sourcetools_0.1.7
  stats_3.6.3       sys_3.3           tools_3.6.3      
  utils_3.6.3       xfun_0.12         xtable_1.8-4     
  yaml_2.2.1        

I also ran update.packages(ask = FALSE, checkBuilt = TRUE) prior to running the above.

Any suggestions on how to debug this?

Thanks

Try using the functions from the DT package. They worked for me.

library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(
  
  # Application title
  titlePanel(""),
  
  # Sidebar with a slider input for number of bins 
  sidebarLayout(
    sidebarPanel(
      
    ),
    
    # Show a plot of the generated distribution
    mainPanel(
      DT::dataTableOutput("reports_table")
    )
  )
)

# Define server logic required to draw a histogram
server <- function(input, output) {
  
  output$reports_table <- DT::renderDataTable({
    iris
  })
}

# Run the application 
shinyApp(ui = ui, server = server)

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

I was able to solve this using DT::DTOutput and DT::renderDT(). Still leaving this question here, if anyone can figure out what is wrong with my original code.

DT::dataTableOutput and DT::renderDataTable did not work for me. I just got a blank div.

Thanks