使用 selectInput 设置框标题?
Use selectInput to set box title?
我想使用 selectInput 来设置框的标题。例如,我希望默认标题为:Name 2 settings
现在,我可以将标题设置为 [1] "Name 2 settings"
。有没有办法删除 [1]
和引号?
谢谢!
这是我的示例应用程序:
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(dashboardHeader(),
dashboardSidebar(),
dashboardBody(fluidRow(
box(
title = "Settings", width = 6, solidHeader = TRUE, status = "primary",
flowLayout(selectInput(
"Design", "Design:",
c("Name 1" = "Name 1",
"Name 2" = "Name 2"),
selected = "Name 2"
))
),
box(
title = textOutput("Design"), width = 4, solidHeader = TRUE, status = "primary",
"Box content"
)
)))
server <- function(input, output) {
output$Design <- renderPrint({
paste(input$Design, 'settings')
})
}
shinyApp(ui, server)
只需将 renderPrint
替换为 renderText
:
server <- function(input, output) {
output$Design <- renderText({
paste(input$Design, 'settings')
})
}
我想使用 selectInput 来设置框的标题。例如,我希望默认标题为:Name 2 settings
现在,我可以将标题设置为 [1] "Name 2 settings"
。有没有办法删除 [1]
和引号?
谢谢!
这是我的示例应用程序:
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(dashboardHeader(),
dashboardSidebar(),
dashboardBody(fluidRow(
box(
title = "Settings", width = 6, solidHeader = TRUE, status = "primary",
flowLayout(selectInput(
"Design", "Design:",
c("Name 1" = "Name 1",
"Name 2" = "Name 2"),
selected = "Name 2"
))
),
box(
title = textOutput("Design"), width = 4, solidHeader = TRUE, status = "primary",
"Box content"
)
)))
server <- function(input, output) {
output$Design <- renderPrint({
paste(input$Design, 'settings')
})
}
shinyApp(ui, server)
只需将 renderPrint
替换为 renderText
:
server <- function(input, output) {
output$Design <- renderText({
paste(input$Design, 'settings')
})
}