1
votes

I would like to display my full data on the shinyapp output. My dataset is 31 columns wide but using DT::renderDataTable i only get at max 17 columns. I need to be able to see or at least be able to scroll to the right and left to view the entire data table on my shiny app. Here is the UI and SERVER code below.

My question: Is this possible to do? Or is there a limit to the number of columns that DT package can display in the shiny app?

ui.interface <- fluidPage(title = "Pokemon Analysis", 
            tabsetPanel(
              ########### Data table below ##############
              tabPanel(title = "Pokemon Go",
                       # plotOutput("go"),
                       titlePanel("Pokemon Go"),
                       # Create a new Row in the UI for selectInputs
                       fluidRow(
                         column(4,
                                selectInput("evostage",
                                            "Evolution Stage:",
                                            c("All",
                                              unique(as.character(dt.pokemon$EvoStage))))
                         ),
                         column(4,
                                selectInput("evo",
                                            "Evolution:",
                                            c("All",
                                              unique(as.character(dt.pokemon$EvolutionPips))))
                         ),
                         column(4,
                                selectInput("battack",
                                            "Attack:",
                                            c("All",
                                              unique(as.character(dt.pokemon$BaseAttack))))
                         )
                       ),
                       # Create a new row for the table.
                       fluidRow(
                         DT::dataTableOutput("table")
                       ))
              ########### Data table above ##############
            )
)

Below is my server code...

server.interface <- function(input, output) {

########### Data table below ##############
output$table <- DT::renderDataTable(DT::datatable({
   data <- pokemon
   if (input$evostage != "All") {
     data <- data[data$EvoStage == input$evostage,]
   }
   if (input$evo != "All") {
     data <- data[data$EvolutionPips == input$evo,]
   }
   if (input$battack != "All") {
    data <- data[data$BaseAttack == input$battack,]
   }
   data
   }))
 ########### Data table above ##############
}
shinyApp(server = server.interface, ui = ui.interface)
1

1 Answers

1
votes

It seems your question is similar to this one. As described in the link above, it is possible to add a horizontal scrollbar by adding options = list(scrollX = TRUE) parameter to the renderDataTable function (after ( and before {).