您好,我有一个示例 df 如下,我正在尝试使用ggpubr带有该stat_compare_means()函数的包执行 t 测试,但是我无法让它在我想要的组之间进行比较:
set.seed(13)
df = data.frame(grouping = c(rep("A",24),rep("B",24),rep("C",24)),
id = c(rep(1,12),rep(2,12),rep(3,12),rep(4,12),rep(5,12),rep(6,12)),
subject = c(rep(c("One","Two","Three","Four"),72)),
family = c(rep(c("Red","Red","Red","Red","Blue","Blue","Blue","Blue","Green","Green","Green","Green"),6)),
percent = sample(1:100,288,replace=T),
result = "Good")
df %>%
ggplot(aes(x=subject,y=percent,group = interaction(subject,grouping))) +
geom_boxplot(outlier.shape = NA) +
geom_point(aes(color = grouping),size=1.75,position = position_dodge(width = 0.75))+
scale_y_continuous(breaks = seq(0, 100, by = 25),limits = c(0,103)) +
facet_grid(result~family,switch = "y") +
scale_x_discrete("") +
theme_minimal() +
stat_compare_means(aes(group = grouping),label="p.signif",
method = "t.test",paired=F,
tip.length=0,step.increase = 0.05)
Run Code Online (Sandbox Code Playgroud)
从图中可以看出,它只有一个“ns”用于统计测试,但是否有可能在所有三个比较中都使用它?我希望测试在 A、B 和 C 的分组变量之间进行,例如在“四”的 3 …
您好,我想问如何在多个组之间绘制与 ggplot 中的线连接的配对数据?一些要使用的示例数据:
set.seed(123)
sample <- data.frame(name = c(rep("Amy",4),rep("Bob",4),rep("Jack",4)),
status = rep(c("Before","After"),6),
test = rep(c("English","English","Math","Math"),3),
score = sample(60:100,12,replace=T))
sample %>% ggplot(aes(x=test,y=score,fill=status)) +
geom_boxplot() + geom_point(size = 2)
Run Code Online (Sandbox Code Playgroud)
test这个想法是在 x 轴和scorey 轴上设置,如下所示,但不是使用箱线图,而是geom_point()按组对个体进行分层status(因此组中的点after位于红色箱线图所在的空间中,并且组中的点before位于蓝色箱线图所在的空间中),并geom_line()连接来自同一组的配对数据点name。谢谢!
如果我有一个整数向量(或者如果我将它放入矩阵中),是否可以使用 ggplot 或其他包来绘制热图,这些包可以将每个点作为圆形而不是平铺?
> counts
[1] 1949 1690 1935 2480 1441 1141 2079 1587 517 1028 535 2180 1692 3916 1784
[16] 3028 1911 1329 1759 1478 1080 2835 2187 3230 2932 3527 1538 1489 1493 1170
[31] 3311 4982 4842 4899 1339 3594 2562 1821 1077 1072 4312 3395 3522 1037 3270
[46] 4813 1686 1955 3290 1288 2592 3717 213 2840 3938 3882 1807 1582 2519 2600
[61] 4093 2318 3028 3074 1833 3453 2539 2665 2491 2696 …Run Code Online (Sandbox Code Playgroud)