My text input displays exactly whatever is typed inside it. But how do I make that same input as the title of my plot? (In this case the plot title should be test123
)
Minimal reproducible example:
library(shiny)
library(ggplot2)
ui <- fluidPage(
titlePanel("test"),
sidebarLayout(
sidebarPanel(
textInput("caption", "Caption", "test123"),
verbatimTextOutput("my_text")
),
mainPanel(
plotOutput("my_plot")
)
)
)
server <- function(input, output) {
output$my_text <- renderText({ input$caption })
output$my_plot <- renderPlot(
ggplot(mtcars, aes(x=cyl, y=mpg)) + geom_point() + ggtitle("default_label")
)
}
shinyApp(ui, server)