我試圖顯示由兩個因素組成的組內的顯著性水平,但我似乎總是得到組之間的顯著性水平,這不是我想要的。
df <- structure(list(Datum = structure(c(2L, 1L, 3L, 1L, 1L, 3L, 1L,
2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 3L, 1L, 2L), .Label = c("2021-04-08",
"2021-05-17", "2021-07-07"), class = "factor"), Soll = c("1202",
"172", "119", "1192", "119", "1189", "1189", "552", "1189", "1192",
"2484", "119", "1189", "1189", "172", "552", "1192", "172", "1189",
"172"), Plot = c("6", "5", "3", "4", "6", "5", "4", "5", "7",
"8", "3", "6", "6", "1", "8", "3", "1", "3", "8", "4"), Entfernung = structure(c(2L,
1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 1L,
1L, 2L, 2L), .Label = c("2", "5"), class = "factor"), Behandlung = structure(c(1L,
1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L,
2L, 1L, 1L), .Label = c("a", "b"), class = "factor"), DGUnkraut = c(3.5,
0, 2.8, 3, 0.3, 2, 1, 3, 0, 0.3, 10, 0, 1.7, 2.5, 0.2, 0.3, 9,
0.3, 2.5, 0.2)), class = "data.frame", row.names = c(NA, -20L
))
這是我迄今為止嘗試過的:
library(tidyverse)
library(ggsignif)
df %>% group_by (Datum, Entfernung)%>%
ggplot(., aes(Entfernung, DGUnkraut , color = Datum))
geom_boxplot()
geom_signif(comparisons =list (c("2","5")),
map_signif_level = T)
所以我想看到三個日期中的每一個的“2”和“5”之間的顯著差異,例如,日期為“2021-04-08”和Entfernung =“2”的紅色箱線圖的顯著性水平" 與 Entfernung = "5" 相比,任何幫助表示贊賞!提前非常感謝:)
uj5u.com熱心網友回復:
Facets 似乎不適用于 {ggsignif},但您可以偽造它們,方法是遍歷您的日期,然后將這些圖拼湊在一起。
下面一種方式
library(ggsignif)
library(patchwork)
df %>%
split(., .$Datum) %>%
map(~{
ggplot(., aes(Entfernung, DGUnkraut , color = Datum))
geom_boxplot()
geom_signif(comparisons =list(c("2","5")),
map_signif_level = T)
scale_x_discrete(drop = FALSE)
}) %>%
wrap_plots() plot_layout(guides = "collect")

轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/371962.html
下一篇:使用向量作為密度的三元圖
