如果我有 2 个级别的变量(条件)并且想要创建一个模型。矩阵 R 会自动将条件B 分配为设计矩阵中的术语。
condition <- as.factor( c("A","A","A","B","B","B"))
df <- data.frame(condition)
design <- model.matrix( ~ condition)
> df
condition
1 A
2 A
3 A
4 B
5 B
6 B
> design
(Intercept) conditionB
1 1 0
2 1 0
3 1 0
4 1 1
5 1 1
6 1 1
attr(,"assign")
[1] 0 1
attr(,"contrasts")
attr(,"contrasts")$condition
[1] "contr.treatment"
问题:我希望得到与条件A 相关的结果。如何在 model.matrix() 中指定它?
(一种解决方法是反转生成的 FC)