我想减少以下数据框:
Subject, Run, Condition, DV
1, 1, 1, 123
1, 1, 2, 456
1, 1, 3, 789
1, 2, 1, 123
1, 2, 2, 456
1, 2, 3, 789
2, 1, 1, 123
2, 1, 2, 456
2, 1, 3, 789
2, 2, 1, 123
2, 2, 2, 456
2, 2, 3, 789
到这个数据框:
Subject, Run, coeff(lm(DV ~ Condition))
1, 1, ???
1, 2, ???
2, 1, ???
2, 2, ???
有关如何处理此事的任何想法?
答案 0 :(得分:0)
您应该使用do
而不是summarize
:
df %>% group_by(Subject, Run) %>%
do(lm = lm(DV ~ Condition,data=.)) %>%
summarize(Subject=Subject,
Run=Run,
Coef=coef(lm)[[2]])