EMMEANS, contrast, ggplot, ggsignif

Hello!

So there is a graph that i did with this code


ggplot(data = means_df, aes(x = FtrialType, y = emmean, fill = Fdev)) +

geom_bar(stat = "identity", position = position_dodge()) +

geom_errorbar(aes(ymin = asymp.LCL, ymax = asymp.UCL),

width = 0.2, position = position_dodge(0.9)) +

labs(x = "Trial Type", y = "Estimated Marginal Mean") +

scale_fill_manual(values = my_colors, name = "Deviation") +

theme_classic() +

theme(legend.position = "top",

axis.text.x = element_text(face = "bold", color = "black", size = 14),

text = element_text(size = 15),

axis.text.y = element_text(color = "black", angle = 0, face = 'bold', size = 14)) +

and i wanted to put the significance asterisks for the Agreement more - Agreement same ; Agreement same - Agreement less ; Disagreement more - Disagreement same ; Disagreement same - Disagreement less,

I tried adding this ``` geom_signif(

data = means_df,

comparisons = list(c("Agreement", "Disagreement")),

map_signif_level = TRUE

)```

but it does not give me what i want,

here are the contrasts :


structure(list(contrast = c("Agreement more - Disagreement more",

"Agreement more - Agreement same", "Agreement more - Disagreement same",

"Agreement more - Agreement less", "Agreement more - Disagreement less",

"Disagreement more - Agreement same", "Disagreement more - Disagreement same",

"Disagreement more - Agreement less", "Disagreement more - Disagreement less",

"Agreement same - Disagreement same", "Agreement same - Agreement less",

"Agreement same - Disagreement less", "Disagreement same - Agreement less",

"Disagreement same - Disagreement less", "Agreement less - Disagreement less"

), estimate = c(13.9891915935062, 4.86211599402995, 15.8193509988165,

8.24054873324312, 17.2804916596388, -9.12707559947629, 1.83015940531028,

-5.74864286026312, 3.29130006613258, 10.9572350047866, 3.37843273921316,

12.4183756656089, -7.5788022655734, 1.4611406608223, 9.03994292639571

), SE = c(0.711188148088369, 0.707389428812583, 0.703854330745656,

0.706270503412219, 0.705520818644373, 0.716550453607522, 0.709653090545637,

0.715844313658603, 0.713583826614235, 0.710576555442431, 0.712675325487783,

0.711948862603882, 0.709004112269533, 0.707981641874268, 0.711517456479972

), df = c(Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf,

Inf, Inf, Inf, Inf), z.ratio = c(19.670169744966, 6.87332294771701,

22.4753195480912, 11.6676948753068, 24.4932413090836, -12.7375198124925,

2.57894939047346, -8.03057697124453, 4.61235238717352, 15.4202033839467,

4.74049348755105, 17.4427916356097, -10.6893629168293, 2.06381150922807,

12.7051597175398), p.value = c(1.94239015196788e-85, 8.55318355795017e-12,

5.42856513627015e-111, 3.49510717863204e-31, 2.61539176658542e-131,

9.1460221266394e-37, 0.0106179969126748, 1.45522989231506e-15,

4.59389162324955e-06, 3.59180158263531e-53, 2.66497881816471e-06,

1.46446360966568e-67, 1.90253973268146e-26, 0.0390355914089589,

1.18620637258798e-36)), class = "data.frame", row.names = c(NA,

15L))```


If anyone has any idea or input it would be amazing! Thanks !! ![🙏|16x16](https://static.xx.fbcdn.net/images/emoji.php/v9/t80/1/16/1f64f.png) ![☺️|16x16](https://static.xx.fbcdn.net/images/emoji.php/v9/tfb/1/16/263a.png)
![RRRRRRRRRRPURER|456x500](upload://8wp4iLEmLphgukbId4ZkImVQjgP.png)

I don't have time to look into this in detail but I suspect that the ggsignif package can do what you want.

If you need more help, please post the output of

dput(means_df)

Put lines with three back ticks before and after the dput() output in your response, like this
```
pasted dput() output goes here
```

> dput(means_df)
structure(list(FtrialType = structure(c(1L, 2L, 1L, 2L, 1L, 2L
), levels = c("Agreement", "Disagreement"), class = "factor"), 
    Fdev = structure(c(1L, 1L, 2L, 2L, 3L, 3L), levels = c("more", 
    "same", "less"), class = "factor"), emmean = c(11.8825470219957, 
    -2.10664457151053, 7.02043102796576, -3.93680397682081, 3.6419982887526, 
    -5.39794463764311), SE = c(2.51574952689745, 2.49482277067567, 
    2.51552445990832, 2.50112024493358, 2.5184876221363, 2.51335370229254
    ), df = c(Inf, Inf, Inf, Inf, Inf, Inf), asymp.LCL = c(6.95176855515304, 
    -6.99640734984527, 2.09009368431587, -8.83890957789461, -1.29414674614448, 
    -10.3240273745469), asymp.UCL = c(16.8133254888384, 2.78311820682422, 
    11.9507683716156, 0.965301624253001, 8.57814332364967, -0.471861900739319
    )), class = c("summary_emm", "data.frame"), row.names = c(NA, 
6L), estName = "emmean", clNames = c("asymp.LCL", "asymp.UCL"
), pri.vars = c("FtrialType", "Fdev"), adjust = "none", side = 0, delta = 0, type = "link", mesg = c("Results are averaged over the levels of: Fupdate", 
"Degrees-of-freedom method: asymptotic", "Confidence level used: 0.95"
), digits = 7L)

Thanks :slight_smile:

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.