So, i'm starting to use shiny and making interactive plots. So far, i've made my first and it looks like this:
The code that i used for this plot was
ui <- fluidPage(titlePanel("Suicide Numbers Per 100k"),
sidebarLayout(sidebarPanel(selectInput("region","Region",choices = unique(df$Country))),
mainPanel(plotOutput("country100kplot"))))
server <- function(input,output){
output$country100kplot <- renderPlot(df%>% filter(Country == input$region) %>% ggplot(aes(x=Year,y=Suicides_per_100k,colour=Generation))+geom_line()+labs(x="",y="Suicides",title = "")+theme(plot.title = element_text(hjust = 0.5)))
}
shinyApp(ui,server)
Here, im only using dpyr,ggplot2 and shiny packages. We have a line plot for each generation ( and the user can select the country ), but the plot can be very noisy as you can see.
Say i only want to see the "Boomer" generation line; i would unmark all the other generation to see only this line plot. How can i do that?
EDIT: I tried to use ggplotly. It worked well for general plots. But i don't know why, it doesn't appear on the Shiny. The ggplotly only appears in my R Viewer, and on the shiny, it shows the original ggplot2 plot:
ggiraph
. It builds on ggplot2 and I think it looks pretty slick. I am not experienced enough with it to put in an answer on it. – Adamplotly::renderPlotly()
instead ofrenderPlot()
, but hard to say. – Adam