0

我有一个数据集:

Count   Group    Time
2       1        123123
1       1         1231231 
45      1          145124
25      2          132451
1       2           434114
52      2            1313

我想在每个手臂上进行分析,即。组 = 1 和组 = 2。所以我需要分析所有计数变量,只针对 group=1,然后只针对 group=2。

4

1 回答 1

0

像这样的东西?

Count <- c(2, 1, 45, 25, 1, 52)
Group <- c(1, 1, 1, 2, 2, 2)
Time  <- c(123123, 1231231, 145124, 132451, 434114, 1313)
df    <- as.data.frame(cbind(Count, Group, Time))

aggregate(c(df$Count), list(df$Group), sum)
aggregate(c(df$Count), list(df$Group), mean)
aggregate(c(df$Time), list(df$Group), sum)
aggregate(c(df$Time), list(df$Group), mean)

glm(Count ~ Time, subset = Group, data = df)
于 2015-04-30T15:32:27.650 回答