cowa
March 12, 2020, 3:34pm
1
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?
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
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 REPR oducible EX ample (reprex) illustrating your issue.
system
Closed
March 22, 2020, 10:23pm
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.