Welcome to the community!
I'm unable to reproduce this odd and undesirable behaviour. See below:
library(ggpubr)
#> Loading required package: ggplot2
#> Loading required package: magrittr
ggboxplot(data = ToothGrowth,
x = "supp",
y = "len") +
stat_compare_means(method = "t.test",
paired = FALSE,
method.args = list(alternative = "greater"))
t.test(formula = (len ~ supp),
data = ToothGrowth,
alternative = "greater",
paired = FALSE)
#>
#> Welch Two Sample t-test
#>
#> data: len by supp
#> t = 1.9153, df = 55.309, p-value = 0.03032
#> alternative hypothesis: true difference in means is greater than 0
#> 95 percent confidence interval:
#> 0.4682687 Inf
#> sample estimates:
#> mean in group OJ mean in group VC
#> 20.66333 16.96333
t.test(x = ToothGrowth$len[ToothGrowth$supp == "OJ"],
y = ToothGrowth$len[ToothGrowth$supp == "VC"],
alternative = "greater",
paired = FALSE)
#>
#> Welch Two Sample t-test
#>
#> data: ToothGrowth$len[ToothGrowth$supp == "OJ"] and ToothGrowth$len[ToothGrowth$supp == "VC"]
#> t = 1.9153, df = 55.309, p-value = 0.03032
#> alternative hypothesis: true difference in means is greater than 0
#> 95 percent confidence interval:
#> 0.4682687 Inf
#> sample estimates:
#> mean of x mean of y
#> 20.66333 16.96333
Created on 2019-03-31 by the reprex package (v0.2.1)
Can you please provide a REPRoducible EXample of your problem?
In case you don't know how to make a reprex, here's a great link: