Both t.test ; why different p-values??t.test()&ggboxplot()

Code:
p <- ggboxplot(dataA[43:70,], x="time", y="dd", color = "time",palette = "jco", add = "jitter")
p+stat_compare_means(method = "t.test")+ylim(50,60)
t.test(dataA[43:56,1],dataA[57:70,1],paired = FALSE)

p-value should be 0.96,I have no idea why p-value is 0.66 in the boxplot. Both t.test!!
Is there anything wrong??

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:

This topic was automatically closed 21 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.