2

I am trying to get the title of a ggplot graph from the selected choice from the radioButton that a user picks. I really appreciate any help.

Here are the relevant pieces of code with faked data:

Sidebar

sidebar <- dashboardSidebar(sidebarMenu(
  menuItem("Dashboard", tabName = "Data", icon = icon("dashboard")),
  radioButtons(inputId = "Partner", label = "Choose Partnership:", selected = "A",
             choices = c("A", "B", "C", "D"))),

Body

body <- dashboardBody( 
   fluidRow(
    tabBox(title = "Company",
    tabPanel("Partner", plotOutput("partner"))))
)

Server

output$partner <- renderPlot({
        all_part  %>% 
        filter(partner == input$Partner) %>%
        ggplot(aes(x=level, fill = level)) +
        geom_bar() +
        ylab("Number of Participants") +
        theme_tufte() +
        ggtitle(" ") +   # How can I get this from the radiobutton choice ?#
        theme(plot.title = element_text(colour="black", size=14, face="bold"), 
              axis.title.x = element_text(color="black", size=10, face="bold"),
              axis.title.y = element_text(color="black", size=10, face="bold")) +
        theme(plot.subtitle = element_text(color="#0066CC", size=12, face="bold")) +
        theme(legend.title = element_text(colour="black", size=10, face="bold")) +
        theme(legend.position = "none") +
        theme(plot.background = element_rect(fill = "#CCFFFF"))  
})

0 Answers0