tabItems 或 datatableoutput 在我這邊表現得很奇怪。如果我通過注釋掉 tabItems(如下所示)使用以下代碼運行應用程式,它會向我顯示表格。但是,當我將 tabItems 放回代碼中時,它在我的瀏覽器中顯示一個空螢屏。根本沒有錯誤資訊。
有人能幫我理解問題出在哪里嗎?
## 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
uj5u.com熱心網友回復:
您需要定義選項卡的樣子,例如
## 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)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/324591.html
上一篇:頭部輸出包括行名而不是??行號
下一篇:為R中不存在的資料創建行
