Datatable not showing in Shiny Dashboard
Data is not displayed in Shinydashboard. He just makes a thin white strip for the box. Running only the datatable function in RStudio displays the data in the RStudio viewer. So what's the correct way to visualize DT data in a brilliant app?
## app.R ##
library(shiny)
library(shinydashboard)
library(htmlwidgets)
library(DT)
library(xtable)
source('../ts01/db.R')
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(tableOutput("table1"))
)
)
)
server <- function(input, output) {
output$table1 <- DT::renderDataTable({
datatable(amount_data)
})
}
shinyApp(ui, server)
+3
source to share
2 answers
You should try the following:
1) tableOutput
rm(list = ls())
library(shiny)
library(shinydashboard)
my_data <- head(mtcars)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(tableOutput("table1"))
)
)
)
server <- function(input, output) {
output$table1 <- renderTable({
my_data
})
}
shinyApp(ui, server)
2) dataTableOutput
rm(list = ls())
library(shiny)
library(DT)
library(shinydashboard)
my_data <- head(mtcars)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(DT::dataTableOutput("table1"))
)
)
)
server <- function(input, output) {
output$table1 <- DT::renderDataTable({
datatable(my_data)
})
}
shinyApp(ui, server)
+5
source to share