Facet_wrap in shiny not working

Hi All,

I am trying to facet inside shiny and it returns x-y plot without facet. Everything works as expected except facet. I tried both facet_wrap and grind. below are part of code:

  tabPanel("Data Exploration",
                       selectInput('xcol', 'X Variable', ""),
                       selectInput('ycol', 'Y Variable', "", selected = ""),
                       selectInput('ide','Group',"",selected=""),
                       selectInput('facet','Facet',"",selected="")
  
observe({
    df1 = data()
    updateSelectInput(session,inputId = 'xcol', label = 'X Variable',
                      choices = names(df1), selected =names(df1)[2])
    updateSelectInput(session,inputId = 'ycol', label = 'Y Variable',
                      choices = names(df1), selected = names(df1)[2])
    updateSelectInput(session,inputId = 'id', label = 'Group',
                      choices = names(df1), selected = names(df1)[2])
    updateSelectInput(session,inputId = 'facet', label = 'Facet',
                      choices = names(df1), selected = names(df1)[2])})

output$Plot2<-renderPlotly({(Plot1<-data()%>%group_by(input$ide)%>%ggplot()+
                                   geom_line(aes_string(x=input$xcol,y=input$ycol,color=input$ide))+
                                   theme_bw())
                  Plot2<-ggplotly(Plot1 + facet_grid(~ input$ide))
                  return(Plot2)})

Thank you,

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.