0

I would like to create a graph for this glmer fit

mod_germ2trait <- glmer(ger_b~species∗treatment+(1|pop), 
         family=binomial, data=d)

but even if I tried I don't know how to manage that with ggplot. ger_b is a binary variable on which I'm testing several treatments (4) of competition for 2 species of plant with the population as random effect; I would like to show the difference about the species*treatment interaction so I tried this :

ggplot(d, aes(x=treatment,y=as.factor(ger_b), 
        fill=species, colour=species) )+
        geom_bar(stat = "identity")

I'm new to this forum and I apologize myself if this question is not appropriate

EDIT :

I tried to follow the instruction about how to make a R reproducible example :

dput(datashare)
structure(list(Plante = 1:20, traitement = structure(c(3L, 3L, 
                                                   3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
                                                   3L, 3L), .Label = c("dense", "mi", "peu", "temoin"), class = "factor"), 
           espece = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("cor", 
                                                                                        "mac"), class = "factor"), ger_b = c(0, 0, 0, 1, 0, 1, 0, 
                                                                                                                             0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0)), row.names = c(NA, 
                                                                                                                                                                                    20L), class = "data.frame")

My main problem is that i'm not able to make a proprer graph from my data, the one im making doesnt make any sense.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. What exactly is wrong with the plot you created? – MrFlick Dec 06 '19 at 21:27
  • Thank you for your answer, I posted a simple reproducible example of my data I hope it's fine. I'm not able to produce a proper plot, the one I'm making with the fonction above doesnt make any sense – Germain Vital Dec 06 '19 at 23:01

0 Answers0