簡體   English   中英

stat_compare_means()提供的p.value與compare_means()或t.test()不同

[英]stat_compare_means() gives different p.value than compare_means() or t.test()

我想用ggplot2繪制數據並使用ggpubr添加p值。 但是繪制的p值與我使用compare_means()t.test()計算的p值不匹配。

這是我的數據:

Group <- rep(c('A'), each=12)
Drug <- rep(c('x','y'), each= 6)
RC <- c(13076,  10814,  14297,  13119,  13616,  5, 19671,   18318,  12058,  17624,  9565,   13689)
mydf <- as.data.frame(cbind(Group,Drug,RC))
mydf$RC <- as.numeric(as.character(mydf$RC))

這是情節的代碼:

library(ggplot2)
library(ggpubr)
ggplot(mydf, aes(x=factor(Group),y=log10(RC)))+
geom_boxplot(aes(color=Drug))+stat_compare_means(aes(group = Drug), method = "t.test", label = "p.format")

顯示的p。值是p = 0.32。 但是,當我使用其他方法計算p.value時,得到的值約為0.149

compare_means(RC~Drug,data=mydf, method = "t.test")

t.test(RC~Drug,data=mydf, exact= FALSE)

這里也解決了類似的問題,但是在這種情況下,與stat_compare_means()t.test()相比, compare_means()給出了另一個結果。 我確保擁有ggpubr的最新版本(ggpubr_0.1.6.999)。

我想念的是什么?

您正在對日志值進行測試:

t.test(log10(RC) ~ Drug, data = mydf, exact = FALSE)
# 0.3237

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM