重复测量data.frame和ggplot

时间:2017-11-24 16:57:51

标签: r dataframe ggplot2

很抱歉,如果这个问题对于大多数人来说可能是超级愚蠢的,但我本周刚开始用R玩这个问题。 我正在尝试构建一个data.frame,其阈值已经为每个主题多次(7个不同的时间点)收集。 这就是我到目前为止组织数据的方式:

library(ggplot2)

Subject <- c("1", "1", "1", "1", "1", "1", "1", "1", 
             "2","2","2","2","2","2","2","2",
             "3","3","3","3","3","3","3","3",
             "4","4","4","4","4","4","4","4")

Time <- rep(c(0,1,2,3,4,5,6,7), each = 7) 

Threshold <- c(-17, -24,    -27,    -40,    -25,    -23,    -37,    -40,
               -11, -12,    -11,    0,  -4, -7, -7, -4,
               -1,  -24,    -38,    -34,    -29,    -14,    -21,    -16,
               18,  -10,    -21,    -10,    -5, -17,    -3, -11)

Group <- c("Active","Active","Active","Active","Active","Active","Active","Active",            "Active","Active","Active","Active","Active","Active","Active","Active",           "Control","Control","Control","Control","Control","Control","Control","Control",
"sham","sham","sham","sham","sham","sham","sham","sham")

根据我的理解,这是数据必须如何安排重复测量(长格式),但现在的问题是:如何选择一个特定主题的一列?假设我想在第1天创建一个包含所有主题阈值平均值的向量。

此外,我如何绘制,可以将所有单个数据与(Mean, Median)叠加到geom_point()图表上进行说明?

非常感谢。

0 个答案:

没有答案