I have a dataTable within a box() in my R Shiny app.
When I change the size of the page, the size of the dataTable doesn't change to stay within its box. My plot outputs within the same box have no problem adjusting size, but the data table does.
Thoughts on fixing the data table width?
Here's some code using R's mpg data set to demonstrate my UI issue. Play around with size of window to see the sizing issue I'm referring to.
library(shiny)
library(shinydashboard)
library(data.table)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(width = 325),
dashboardBody(
fluidPage(
box( width = 12,
tabsetPanel(
tabPanel("Summary",
dataTableOutput("coeffTable"))
)
)
)))
server <- function(input, output){
data<-mpg
output$coeffTable<-renderDataTable({
data.table(data[,1:2])
},options = list(lengthMenu = c(5, 10, -1), pageLength = 5))
}
shinyApp(ui = ui, server = server)
This works with the DT
package. To use like this:
library(DT)
output$coeffTable <- DT::renderDataTable({...
DT::dataTableOutput("coeffTable")