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')})
}
答案 0 :(得分:1)
找到解决方案,你必须使用:
当!important
中的aes_string
和aes
变量为x
时, y
代替input$
。
希望这能节省一些时间!