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 1, 1, 1, 1, 1, 
1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3), .Dim = c(252L, 2L), .Dimnames = list(NULL, c("pMRMW", 
"group")))

aggregate(pMRMW~group,data=sample,shapiro.test)

返回

corrupt data frame: columns will be truncated or padded with NAs

其他功能按预期工作。

我错过了一些完全明显的东西吗?

4

1 回答 1

3

出现问题是因为 shapiro.test() 返回 4 个值的列表。

如果你需要 p 值,那么你可以做

 aggregate(pMRMW~group,data=sample,function (x) shapiro.test(x)$p.value)
   group        pMRMW
1     1 0.0064932854
2     2 0.0006112324
3     3 0.0044895909
于 2012-12-06T16:15:34.360 回答