【发布时间】:2017-11-15 04:18:21
【问题描述】:
我的 Shiny 应用程序中的“selectInput”和“updateSelectInput”组合出现问题(我是 Shiny 的新手,但似乎无法在任何地方找到该问题的答案)。我想用 html 标签格式化标签,如下面的基本示例所示(例如,分成两行,更改字体大小)。这适用于“selectInput”,但“updateSelectInput”无法消化相同的标签并输出“[object Object]”。在我看来,它无法处理 html 标签。有什么解决方法吗???谢谢!
ui.R:
# Load libraries needed for app
library(shiny)
library(shinydashboard)
# Define the overall UI with a dashboard page template
shinyUI(
dashboardPage(
dashboardHeader(title = "dashboard header"),
dashboardSidebar(
#Create first dropdown box
selectInput("choice1", "First choice:",1:5,selected=NULL),
#Create second dropdown box
selectInput("choice2", p("Then, make your ", tags$br(), tags$small("second choice")), c("a","b","c","d","e"))
),
dashboardBody()
)
)
server.R:
# Load libraries needed for app
library(shiny)
library(shinydashboard)
# Define server for the Shiny app
shinyServer(function(input, output,session) {
# populate second dropdown box when a choice in first dropdown box is made
observe({
updateSelectInput(session, "choice2", p("Then, make your ", tags$br(), tags$small("second choice")), c("a","b","c","d","e"))
})
})
【问题讨论】:
标签: r shiny shinydashboard