我想通过使用R的t.test命令的子集参数来选择数据帧的646行以外的所有行.我试过了:
require(mosaic)
require(Sleuth3)
t.test(Dioxin~Veteran,data=case0302,var.equal=TRUE,alternative="less",
subset=case0302[-646,])
Run Code Online (Sandbox Code Playgroud)
但那没用.有什么建议?
您只需指定要删除的案例的向量,例如:
test <- data.frame(x=rnorm(100),y=rep(1:2,each=50))
t.test(x ~ y, data=test, subset=-40)
Run Code Online (Sandbox Code Playgroud)
所以在你的情况下它应该是:
t.test(Dioxin~Veteran,data=case0302,var.equal=TRUE,alternative="less",
subset=-646)
Run Code Online (Sandbox Code Playgroud)
正如@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’.
Run Code Online (Sandbox Code Playgroud)