Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use selectInput to set box title?

I want to use selectInput to set the title on a box. For example, I would like the default title to be: Name 2 settings

Right now, I'm able to get the title to be [1] "Name 2 settings". Is there a way to remove the [1] and the quotes?

Thanks!

This is my sample app:

## 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)
like image 949
Ignacio Avatar asked Jul 06 '15 16:07

Ignacio


1 Answers

Just replace renderPrint with renderText:

server <- function(input, output) {
    output$Design <- renderText({
        paste(input$Design, 'settings')
    })
}
like image 132
zero323 Avatar answered Nov 07 '22 15:11

zero323