我有一个看起来像这样的数据框:
structure(list(group = c("A", "B", "C"), mean_meth1 = c(10, 20,
30), mean_meth2 = c(15, 25, 35), lower_meth1 = c(7, 17, 27),
lower_meth2 = c(12, 22, 32), upper_meth1 = c(13, 23, 33),
upper_meth2 = c(18, 28, 38)), class = "data.frame", row.names = c(NA,
-3L))
group mean_meth1 mean_meth2 lower_meth1 lower_meth2 upper_meth1 upper_meth2
1 A 10 15 7 12 13 18
2 B 20 25 17 22 23 28
3 C 30 35 27 32 33 38
3 行用于 3 个不同的组,A、B、C,每组进行两次实验。每种方法都有一个平均值、一个上限和一个下限。我需要绘制这个结构,如果我能得到以下形状的 data.frame 会更容易:
group method mean lower upper
1 A meth1 10 7 13
2 A meth2 15 12 18
3 B meth1 20 17 23
4 B meth2 25 22 28
5 C meth1 30 27 33
6 C meth2 35 32 38
我尝试过,pivot_longer但我没有太多。你们能帮帮我吗?谢谢pivot_widerdplyr