0

I already created the box with the options, but I don't know how to make the graph change according to the selected column, I need that the y exe be output$SelectTiempo and the colour of the graphic be the output$SelectProfesional, and if you have some other advice that you think that can help me, I really appreciate it

Server

output$Selectproce<-renderUI({
  selectInput("Selectproce", "Seleccione Procedimiento",
              BDnuevo$procedureCodes.0.name, multiple = T, selected = TRUE)
})

BD6.2<-reactive({
  BDnuevo %>%
    filter(procedureCodes.0.name %in% input$Selectproce)
})

output$SelectProfesional<-renderUI({
  selectInput("SelectProfesional", "Seleccione perfil",
              choices = c("Inversionistas"="FullnameI" , "Deudores"="FullnameD", "Autores"="FullnameA")
              )
})

output$SelectTiempo <-renderUI({
  selectInput("SelectTiempo", "Seleccione indicador",
              choices = c( "TiempoR" = "RoomList", "TiempoS"="SpacioTime"))
})


Fechasd<-reactive({
  BD6.3<-BD6.2()
  unique(BD6.3$simpleOriginDate)
})
output$RandeDated<-renderUI({
  dateRangeInput('dateRange6',
                 label = 'Seleccione un rango',
                 start = min(Fechasd(),na.rm=T), max(Fechasd(),na.rm=T)
                 )
})
BD6.4<-reactive({
  BD6.5<-BD6.2()
  BD6.5 %>%
    filter(simpleOriginDate >= input$dateRange6[1] &
             simpleOriginDate <= input$dateRange6[2])
})
output$lineplotTS <- renderPlot({
  BD6.5<-BD6.4()
  subset (BD6.5,BD6.5$times.simpleMinutesRecoverTime >=1 &
                  BD6.5$times.simpleMinutesRecoverTime <= 1000) %>%
    ggplot(aes(x = simpleOriginDate, y =??????????????????? , colour = ?????????????)) +
    geom_point() +
    scale_x_date(date_breaks = "1 month", date_labels =  "%b %Y") +
    theme(axis.text.x=element_text(angle=45, hjust=1))
})
r2evans
  • 141,215
  • 6
  • 77
  • 149
ErikaC
  • 65
  • 6
  • 1
    ErikaC, I suggested an edit to your code for two reasons: (1) it was syntactically invalid, where consecutive lines/expressions were combined onto one line without a `;` to separate them, thus errosr; (2) it is harder to use when everything is prepended by `>`, so I removed all of them (mostly convenience, little bit of readability). Hope it is clear. – r2evans Dec 17 '20 at 15:35
  • Welcome to SO! Please provide a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), i.e. a minimal, complete (also ui part) running shiny app and some example data (with the output of `dput`), then it's easier to help you. Thanks! – starja Dec 17 '20 at 21:53

1 Answers1

0

Easily interface ggplot with shiny inputs by:

[Preferred Method] wrapping inputs in .data[[ ... ]], e.g. y = .data[[input$SelectTiempo]]

[Deprecated Method] using aes_string instead of aes. Then use quotes on regular variables (e.g. x = "simpleOriginDate"), and refer to inputs in this way: y = input$SelectTiempo

da11an
  • 701
  • 4
  • 8
  • 1
    I think this is deprecated, now the recommended way is to use `aes` in combination with `.data`, e.g. `aes(y = .data[[input$SelectTiempo]])` – starja Dec 18 '20 at 08:13