数据 table 在 shinydashboard 中不起作用
Data table will not work in shinydashboard
如果 shinydashboard 是一个人,我想拿着棒球棒在黑暗的小巷里见他。我只是想在我闪亮的应用程序中将数据框显示为 table,所以我在网上查看了一堆网站和关于堆栈交换的问题,这就是我得到的。
UI
library(shiny)
library(shinydashboard)
library(data.table)#For fread.
library(tidyverse)
library(htmlwidgets)
library(DT)#For the interactive table.
# Header -----------------------------------------------------------------------|
header<-dashboardHeader( title = "Marketing Dashboard"
)
# Sidebar ----------------------------------------------------------------------|
sidebar<-dashboardSidebar(
sidebarMenu(
menuItem("Overview", tabname ="overview", icon = icon("dashboard")),
menuItem("Weather", tabname ="weather", icon = icon("bolt"))
)
)
# Body -------------------------------------------------------------------------|
body<-dashboardBody(
tabItems(
tabItem(tabName = 'overview',
DT::dataTableOutput("overviewtable")
),
tabItem(tabName = 'weather',
fluidRow(
)
)
)
)
# UI ---------------------------------------------------------------------------|
ui = dashboardPage(
header,
sidebar,
body
)
shinyApp(ui,server)
服务器
server <- function(input,output){
#Table for overview
output$overviewtable<- DT::renderDataTable({
DT::datatable(tib1)
})
}
我试过使用 tableOutput
和 renderTable
我试图查看我的 tib1 是否有问题,所以我尝试使用数据集 mpg。那没有用。我尝试将 DT::dataTableOutput("overviewtable")
放在 fluidRow 的 column() 中。我尝试重新安装 DT 的软件包并刷新 R,但这没有用。我从 R here 查看了画廊网站。我拿了那个代码 运行 它并且我能够看到他们制作的 table 但是当我 运行 我的代码时我根本看不到我的 table 或其他 tables 就此而言。我觉得它与 shinydashboard 有关,因为当我 运行 上面网站的代码只是使用 shiny 时,它似乎起作用了。
问题是 tabName =
参数中的错字:
sidebar<-dashboardSidebar(
sidebarMenu(
menuItem("Overview", tabName ="overview", icon = icon("dashboard")),
menuItem("Weather", tabName ="weather", icon = icon("bolt"))
)
)
如果 shinydashboard 是一个人,我想拿着棒球棒在黑暗的小巷里见他。我只是想在我闪亮的应用程序中将数据框显示为 table,所以我在网上查看了一堆网站和关于堆栈交换的问题,这就是我得到的。
UI
library(shiny)
library(shinydashboard)
library(data.table)#For fread.
library(tidyverse)
library(htmlwidgets)
library(DT)#For the interactive table.
# Header -----------------------------------------------------------------------|
header<-dashboardHeader( title = "Marketing Dashboard"
)
# Sidebar ----------------------------------------------------------------------|
sidebar<-dashboardSidebar(
sidebarMenu(
menuItem("Overview", tabname ="overview", icon = icon("dashboard")),
menuItem("Weather", tabname ="weather", icon = icon("bolt"))
)
)
# Body -------------------------------------------------------------------------|
body<-dashboardBody(
tabItems(
tabItem(tabName = 'overview',
DT::dataTableOutput("overviewtable")
),
tabItem(tabName = 'weather',
fluidRow(
)
)
)
)
# UI ---------------------------------------------------------------------------|
ui = dashboardPage(
header,
sidebar,
body
)
shinyApp(ui,server)
服务器
server <- function(input,output){
#Table for overview
output$overviewtable<- DT::renderDataTable({
DT::datatable(tib1)
})
}
我试过使用 tableOutput
和 renderTable
我试图查看我的 tib1 是否有问题,所以我尝试使用数据集 mpg。那没有用。我尝试将 DT::dataTableOutput("overviewtable")
放在 fluidRow 的 column() 中。我尝试重新安装 DT 的软件包并刷新 R,但这没有用。我从 R here 查看了画廊网站。我拿了那个代码 运行 它并且我能够看到他们制作的 table 但是当我 运行 我的代码时我根本看不到我的 table 或其他 tables 就此而言。我觉得它与 shinydashboard 有关,因为当我 运行 上面网站的代码只是使用 shiny 时,它似乎起作用了。
问题是 tabName =
参数中的错字:
sidebar<-dashboardSidebar(
sidebarMenu(
menuItem("Overview", tabName ="overview", icon = icon("dashboard")),
menuItem("Weather", tabName ="weather", icon = icon("bolt"))
)
)