如何在 ShinyDashboard 中指定 menuItem?
How to specify menuItem in ShinyDashboard?
我正在使用 shinydashboard
包版本 0.7.1 创建 Shiny 网络应用。
所以我遇到了一个问题,当我指定 menuItem
.
时没有任何反应
示例如下:
library(shinydashboard)
library(sqldf)
library(DBI)
library(foreign)
library(RPostgres)
library(stringr)
library(readxl)
library(ggplot2)
library(ggpubr)
library(formattable)
library(reshape2)
header <- dashboardHeader(title = "S-T")
sidebar <- dashboardSidebar(
textInput("banc_lics", "No of license", value=1),
dateInput("date_an", "Input date", value = "2019-02-01" ),
sidebarMenu(
sidebarMenu(
menuItem("Credit Risk", tabName = "Credit Risk", icon("abacus")),
menuItem("Equity Risk", tabName = "Equity Risk", icon("wave-tiangle")))
),
submitButton("Submit", icon("calculator"))
)
page <- dashboardBody(
tabItems(
tabItem(
tabName = "Credit Risk", h1("Credit Risk"),
fluidRow(
box(width=12, title = "Таблица", tableOutput("data_table"))
),
fluidRow(
box(width=12, title = "График", plotOutput("data_plot"))
)
),
tabItem(tabName = "Equity Risk", h2("Equity Risk"))
)
)
ui <- dashboardPage(header, sidebar, page, skin="yellow")
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
我没有在正文中看到预先指定的 data_table
和 data_plot
。
有什么办法可以解决这个问题吗?
谢谢。
需要更改的内容很少...
- 你有一个多余的
sidebarMenu()
是不必要的
- 您需要
icon("x")
为 icon = icon("x")
完整代码:
library(shinydashboard)
header <- dashboardHeader(title = "S-T")
sidebar <- dashboardSidebar(
textInput("banc_lics", "No of license", value=1),
dateInput("date_an", "Input date", value = "2019-02-01" ),
sidebarMenu(
menuItem("Credit Risk", tabName = "CR", icon = icon("abacus")),
menuItem("Equity Risk", tabName = "ER", icon = icon("wave-tiangle"))
),
submitButton("Submit", icon("calculator"))
)
body <- dashboardBody(
tabItems(
tabItem(tabName = "CR",
h1("Credit Risk"),
fluidRow(
box(width=12, title = "Таблица", tableOutput("data_table"))
),
fluidRow(
box(width=12, title = "График", plotOutput("data_plot"))
)
),
tabItem(tabName = "ER",
h2("Equity Risk")
)
)
)
ui <- dashboardPage(header, sidebar, body, skin="yellow")
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
我正在使用 shinydashboard
包版本 0.7.1 创建 Shiny 网络应用。
所以我遇到了一个问题,当我指定 menuItem
.
示例如下:
library(shinydashboard)
library(sqldf)
library(DBI)
library(foreign)
library(RPostgres)
library(stringr)
library(readxl)
library(ggplot2)
library(ggpubr)
library(formattable)
library(reshape2)
header <- dashboardHeader(title = "S-T")
sidebar <- dashboardSidebar(
textInput("banc_lics", "No of license", value=1),
dateInput("date_an", "Input date", value = "2019-02-01" ),
sidebarMenu(
sidebarMenu(
menuItem("Credit Risk", tabName = "Credit Risk", icon("abacus")),
menuItem("Equity Risk", tabName = "Equity Risk", icon("wave-tiangle")))
),
submitButton("Submit", icon("calculator"))
)
page <- dashboardBody(
tabItems(
tabItem(
tabName = "Credit Risk", h1("Credit Risk"),
fluidRow(
box(width=12, title = "Таблица", tableOutput("data_table"))
),
fluidRow(
box(width=12, title = "График", plotOutput("data_plot"))
)
),
tabItem(tabName = "Equity Risk", h2("Equity Risk"))
)
)
ui <- dashboardPage(header, sidebar, page, skin="yellow")
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
我没有在正文中看到预先指定的 data_table
和 data_plot
。
有什么办法可以解决这个问题吗?
谢谢。
需要更改的内容很少...
- 你有一个多余的
sidebarMenu()
是不必要的 - 您需要
icon("x")
为icon = icon("x")
完整代码:
library(shinydashboard)
header <- dashboardHeader(title = "S-T")
sidebar <- dashboardSidebar(
textInput("banc_lics", "No of license", value=1),
dateInput("date_an", "Input date", value = "2019-02-01" ),
sidebarMenu(
menuItem("Credit Risk", tabName = "CR", icon = icon("abacus")),
menuItem("Equity Risk", tabName = "ER", icon = icon("wave-tiangle"))
),
submitButton("Submit", icon("calculator"))
)
body <- dashboardBody(
tabItems(
tabItem(tabName = "CR",
h1("Credit Risk"),
fluidRow(
box(width=12, title = "Таблица", tableOutput("data_table"))
),
fluidRow(
box(width=12, title = "График", plotOutput("data_plot"))
)
),
tabItem(tabName = "ER",
h2("Equity Risk")
)
)
)
ui <- dashboardPage(header, sidebar, body, skin="yellow")
server <- function(input, output) {}
shinyApp(ui = ui, server = server)