我正在查看具有 2 個治療組(hifat 或無 hifat 飲食)的豚鼠的生物學資料,當我 facet_wrap 箱線圖并添加 stat_compare_means (t.test) 函式時,p 值被截斷。當我洗掉 scales="free" 時,它仍然會切斷 p 值。我使用該函式來移動措辭,但由于所有圖表都有不同的比例,例如在 y=1 處的固定值將強制所有軸相同。希望得到任何指導。
library(tidyverse)
library(ggforce)
library(ggpubr)
ex <- data.frame(hifat=rep(c('yes','no'),each=8),
treat=rep(rep(c('bmi','heart'),4),each=4),
value=rnorm(32) rep(c(3,1,4,2),each=4))
ex %>%
ggplot(aes(x = hifat,
y = value))
geom_boxplot()
geom_point()
stat_compare_means(method = "t.test")
facet_wrap(~ treat, scales = "free")
uj5u.com熱心網友回復:
編輯
感謝您編輯您的問題以添加示例資料集!這是一個潛在的解決方案:
library(tidyverse)
library(ggforce)
library(ggpubr)
ex <- data.frame(hifat=rep(c('yes','no'),each=8),
treat=rep(rep(c('bmi','heart'),4),each=4),
value=rnorm(32) rep(c(3,1,4,2),each=4))
ex %>%
ggplot(aes(x = hifat,
y = value))
geom_boxplot()
geom_point()
stat_compare_means(method = "t.test",
position = position_nudge(y = 0.5))
facet_wrap(~ treat, scales = "free")

由
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/440260.html
