Either the tabItems or the datatableoutput is behaving strange on my side. If I run the app with below code by commenting out the tabItems (as shown below), it shows me the table. But, when I put the tabItems back into the code, it shows an empty screen in my browser. There is no error message at all.
Can anybody help me understand where the problem lies?
## app.R ##
library(shiny)
library(shinydashboard)
library(DT)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
# tabItems(
# tabItem(
tabName = "dashboard",
fluidRow(
column(
width = 8,
align = "center",
dataTableOutput("tbl_cars")
)
)
# )
# )
)
)
server <- function(input, output) {
output$tbl_cars <- renderDataTable({
datatable(mtcars)
})
}
shinyApp(ui, server)
## sessionInfo() ##
locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8
[6] LC_MESSAGES=C.UTF-8 LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DT_0.19 shinydashboard_0.7.2 shiny_1.7.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.7 rstudioapi_0.13 magrittr_2.0.1 xtable_1.8-4 R6_2.5.1 rlang_0.4.11
[7] fastmap_1.1.0 tools_4.1.1 cli_3.0.1 jquerylib_0.1.4 withr_2.4.2 crosstalk_1.1.1
[13] htmltools_0.5.2 ellipsis_0.3.2 yaml_2.2.1 digest_0.6.28 fontawesome_0.2.2 lifecycle_1.0.1
[19] crayon_1.4.1 later_1.3.0 htmlwidgets_1.5.4 sass_0.4.0 promises_1.2.0.1 cachem_1.0.6
[25] mime_0.12 compiler_4.1.1 bslib_0.3.1 jsonlite_1.7.2 httpuv_1.6.3
CodePudding user response:
You need to define what the tab will be like e.g
## app.R ##
library(shiny)
library(shinydashboard)
library(DT)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"))
)),
dashboardBody(
tabItems(
tabItem(
tabName = "dashboard",
fluidRow(
column(
width = 8,
align = "center",
dataTableOutput("tbl_cars")
)
)
)
)
)
)
server <- function(input, output) {
output$tbl_cars <- renderDataTable({
datatable(mtcars)
})
}
shinyApp(ui, server)