r - 在条形图ggplot2中添加带有子组的条形之间的显着性括号
问题描述
我正在尝试创建一个带有括号的图形,表示我的条形图的子级别之间的重要性。目标是根据 Wilcoxon 测试的结果创建如下所示的内容:
但是,我似乎无法弄清楚如何包含比较子级别的括号(Active 1 Week Post 到 Sham 1 Week Post;Active 8 Weeks Post 到 Sham 8 Weeks Post)。
这是我的数据:
dat_ex <- dput(dat_ex)
structure(list(id = c("Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 1",
"Participant 1", "Participant 1", "Participant 1", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2", "Participant 2", "Participant 2", "Participant 2",
"Participant 2"), item_num = c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5,
6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14,
15, 15, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 1, 1, 2, 2, 3,
3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12,
13, 13, 14, 14, 15, 15, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7,
7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15,
1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 1, 1, 2, 2, 3, 3, 4,
4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13,
13, 14, 14, 15, 15, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,
8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 1,
1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11,
11, 12, 12, 13, 13, 14, 14, 15, 15), tdcs = c("active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active",
"sham", "active", "sham", "active", "sham", "active", "sham",
"active", "sham", "active", "sham", "active", "sham", "active"
), One_Week_Post = c(1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0,
1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0,
1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1,
1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1,
1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1), time_point2 = c("Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Baseline",
"Baseline", "Baseline", "Baseline", "Baseline", "Baseline", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post",
"Eight_Weeks_Post", "Eight_Weeks_Post", "Eight_Weeks_Post"),
score = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1,
1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), change = c("Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1",
"Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto1", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8",
"Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8", "Bto8"),
chgbroad = c(0, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 1, 0, 1,
1, -1, -1, 0, -1, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
-1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, -1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, -1, 0, 0, 0, -1,
0, 0, 1, 0, 1, 1, -1, -1, 0, -1, 0, 1, -1, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, -1, 1, 0, 1, 0, 0, 1, 1, 0, -1, 0, 0, 0,
0, 0, 0, 0, -1, -1, 0, 0, 1, 1, -1, 0, -1, 0, -1, 1, -1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0,
0, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 1, 1, -1, 0, -1,
0, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1,
0, 0, 0, 0, 0)), row.names = c(NA, -240L), class = c("tbl_df",
"tbl", "data.frame"))
这是我没有括号的情节的代码:
sum_dat_ex <-
dat_ex %>%
group_by(id,tdcs, change) %>%
summarise(chgacc = mean(chgbroad), se = std.error(chgbroad), sd = sd(chgbroad)) %>%
mutate(chgacc = if_else(chgacc == 0,-0.0017,chgacc)) %>%
mutate(se = if_else(chgacc < 0, se*-1,se)) %>%
mutate(ast_space = if_else(chgacc < 0, -0.02,0.02)) %>%
mutate(signif_Bto1 = (if_else((id == 'Participant 2' & tdcs == 'active' & change == 'Bto1'), '1','0'))) %>%
mutate(signif_Bto8 = (if_else((id == 'Participant 1' & tdcs == 'sham' & change == 'Bto8'),'1','0')))
sum_dat_ex
# Creating Barplot:
colorpicks <- c("blue", "red")
barplot <-ggplot(data=sum_dat_ex,
aes(x=tdcs, y=chgacc, fill = change)) +
#scale_fill_manual("change",name = "Follow up Time Point", values = colorpicks)+
geom_col(width = 0.7, position = position_dodge(0.7)) +
facet_wrap(~id, dir = "h") +
scale_fill_manual(values = colorpicks, labels = c('1 Week Post','8 Weeks Post'))+
geom_text(data = sum_dat_ex[sum_dat_ex$signif_Bto1 == "1", ],
aes(y=chgacc + se + ast_space, label="*"), size=7, nudge_x = -0.175)+ # y=chgacc + (-1*.02), nudge_x = 0.25
geom_text(data = sum_dat_ex[sum_dat_ex$signif_Bto8 == "1", ],
aes(y=chgacc + se + ast_space, label="*"), size=7, nudge_x = 0.175)+ # y=chgacc + (-1*.02), nudge_x = 0.25
scale_x_discrete(labels = c('Active','Sham'))+ # Only needed for graphs on the bottom
scale_y_continuous(labels = scales::label_percent(accuracy = 1), limits = (c(-.35,.4))) +
labs(y = "Change from Baseline", fill = 'Follow up Time Point')+
geom_errorbar(aes(ymin=chgacc-se,ymax=chgacc+se), width = 0, position = position_dodge(.7))
barplot
这是我尝试创建括号的内容:
stat.test1 <- dat_ex %>%
dplyr::filter(change == 'Bto1') %>%
group_by(id) %>%
wilcox_test(chgbroad ~ tdcs) %>%
adjust_pvalue(method = "fdr") %>%
add_significance("p.adj")
stat.test1
stat.test1 <- stat.test1 %>% add_xy_position(x = 'tdcs')
barplot+ stat_pvalue_manual(stat.test1)
stat.test2 <- dat_ex %>%
dplyr::filter(change == 'Bto8') %>%
group_by(id) %>%
wilcox_test(chgbroad ~ tdcs) %>%
adjust_pvalue(method = "fdr") %>%
add_significance("p.adj")
stat.test2
stat.test1 <- stat.test1 %>% add_xy_position(x = 'tdcs')
barplot + stat_pvalue_manual(stat.test1)
但我得到的错误是“FUN 中的错误(X[[i]],...):找不到对象'更改'”
是否有可能做到这一点?还是我需要手动创建括号?
解决方案
推荐阅读
- python - 在 django 中更新值
- c# - HTTP 错误 500.30 - ANCM 进程内启动失败 - “Microsoft.Data.SqlClient.TdsParser”引发异常
- json - 在 REST API 中发送汉字字符时出现问题
- macos - Apple Mac M1:VipsOperation:找不到类“webpsave_buffer”
- android - 如何在 Rubymotion webview 中添加确认 AlertDialog?
- r - 简化嵌套的 lapplys
- scala - Flink Cassandra 不支持给定 DataStream 的类型:GenericType
- javascript - React-Router 参数不可访问
- r - 使用 openxlsx 将 Excel 数据导入 R:文件中的错误(con,“r”):无效的“描述”参数
- python - Numpy exp() 不可调用