Reputation: 252
I'm trying to create a scatter plot in R shiny where the user selects X and Y from columns of a reactive combodf1()
which was built from other reactives. If you set the input to x
and y
and the column names directly, it works, but setting them from input$metric_a
etc (you can see the names of the choices and combodf1()
's cols are the same), the data is not present. Any help here would be really appreciated!
Part of the UI:
selectInput("metric_a", "metric_a:",
c("Buzz" = "buzz",
"Aided" = "aided",
"Adaware" = "adaware")),
selectInput("metric_b", label = ("Metric B"),
c("Buzz" = "buzz",
"Aided" = "aided",
"Adaware" = "adaware")),
Part of the server:
combotest<- reactive({do.call(cbind, list(adaware()$Value, buzz()$Value, aided()$Value))})
combodf<- reactive({as.data.frame(combotest())})
# Renaming reactive cols - WORKS, PLYR function
combodf1<-reactive({rename(combodf(), c("V1"="adaware", "V2"='buzz', 'V3' = 'aided'))})
# PLOT
output$plot2<-renderPlot({
ggplot(data=combodf1(),aes(x=input$metric_a,y=input$metric_b))+geom_point(colour='red')})
}
Upvotes: 0
Views: 484
Reputation: 252
Found the solution, you have to use:
aes_string
instead of aes
when your x
and y
are input$
variables in GGPlot
.
Hope this saves someone some time!
Upvotes: 2