Creating ggplots bar diagram in Shiny

I have a data frame (df) like this

  Block    RTreg    RTrnd
1 Block1   0.0000 862.0707 
2 Block2 667.2081 770.4315 
3 Block3 645.4730 696.0200
4 Block4 674.5200 659.4765
5 Block5 651.4295 633.7333

and I used this code for box plot

library(reshape2)
df.long<-melt(df)
ggplot(df.long,aes(Block,value,fill=variable))+
     geom_bar(stat="identity",position="dodge")

same code I was trying to run with R shiny based on the user input, like input$show_vars3 will be Block1,Block4.... and $show_vars4 will be RTrnd, RTreg

 output$plot7 <- renderPlot({
    df.long<-melt(c(input$show_vars3,input$show_vars4))
    ggplot(df.long,aes(input$show_vars3,value,fill=names(input$show_vars4)))+geom_bar(stat="identity",position="dodge")

There is no plot were generated based on the code
Where I am missing ?

@cowa it's hard to say. Can you provide a reproducible example of your shiny app?

Try with aes_string(), it should be something like this although I can't test it since you haven't provided a reproducible example.

ggplot(df.long, aes_string(x = input$show_vars3,
                                       y = "value",
                                       fill = input$show_vars4)) + 
            geom_col(position = "dodge")

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

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