rplotshinylevelplot

How can I concatenate non-reactive values with reactive value for a graph title? R Shiny


I am having trouble naming a graph title that contains a normal string AND reactive value/s.

I'm trying to do something like this: main = "Examination of: " + input$userInput

The error message is: non-numeric argument to binary operator. Does anyone know how to fix this?


Solution

  • The below code could give you what you needed.

    library(shiny)
    ui <- basicPage(
      uiOutput("test"),
      plotOutput("plot1")
    )
    server <- function(input, output) {
      output$test <- renderUI({
        selectInput("dummy", "Select one value", c(mtcars$qsec))
      })
      output$plot1 <- renderPlot({
        plot(mtcars$wt, mtcars$mpg, main = paste0("this is main ",input$dummy,""))
      })
    }
    shinyApp(ui, server)
    

    The usage of selectInput is for testing your requirement. Make the needful changes for your actual problem.