1

I want to add the significance level of a comparison between 2 independent groups using stat_compare_means() of the ggpubr package.

When using method = "t.test", the function will run a Welch t-test assuming the variances are not equal.

If using base R t.test() I'd add var.equal=TRUE, but I couldn't find a way to do so in ggpubr?

ggstripchart(dat, x = "Group", error.plot = "errorbar", # Add error bars 
with SD
y = "tcm_cd4", combine = TRUE, color = "Group", size = 7, # Size of 
# shapes.
shape = "Group", # Change shape according to Group
add = c("mean_sd", "mean"),
jitter = 0.2, add.params = list(size = 1.4, color = "darkblue"),
font.label = list(size = 14, face = "bold")) + 
stat_compare_means(method = "t.test", label = "p.format", 
bracket.size = 1, 
tip.length = 0,
comparisons=list(c(1,2), c(1,3), c(2,3)))

I need the function to run a t-test assuming the variances are equal.

Martin Evans
  • 45,791
  • 17
  • 81
  • 97
  • 2
    You'll need to include some or all of `dat` to [make this question reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – neilfws May 15 '19 at 00:05

1 Answers1

4

Difficult to answer without data but have you tried the method.args = argument ?

+ stat_compare_means(method = "t.test",
                     method.args = list(var.equal = TRUE), 
                     label = "p.format", 
                     bracket.size = 1, 
                     tip.length = 0,
                     comparisons=list(c(1,2), c(1,3), c(2,3)))
neilfws
  • 32,751
  • 5
  • 50
  • 63