我想通过使用R的t.test命令的子集参数来选择数据帧的646行以外的所有行。我试过了:
require(mosaic)
require(Sleuth3)
t.test(Dioxin~Veteran,data=case0302,var.equal=TRUE,alternative="less",
subset=case0302[-646,])
但那没用。有什么建议吗?
答案 0 :(得分:5)
您只需指定要删除的案例的向量,例如:
test <- data.frame(x=rnorm(100),y=rep(1:2,each=50))
t.test(x ~ y, data=test, subset=-40)
所以在你的情况下它应该是:
t.test(Dioxin~Veteran,data=case0302,var.equal=TRUE,alternative="less",
subset=-646)
正如@flodel所说,subset=
中提供了有关?model.frame
参数的更多信息:
subset: a specification of the rows to be used: defaults to all rows.
This can be any valid indexing vector (see ‘[.data.frame’)
for the rows of ‘data’ or if that is not supplied, a data
frame made up of the variables used in ‘formula’.