如何以
的方式修改此代码(或添加更多功能)示例:
responseList <- names(mtcars)[-c(4,9)]
modelList <- lapply(responseList, function(resp) {
mF <- formula(paste(resp, " ~ hp * am"))
aov(mF, data = mtcars)
})
summaries <- lapply(modelList, summary)
resid <- lapply(modelList, resid)
normal <- lapply(resid, function(x) shapiro.test(x))
答案 0 :(得分:0)
[1]
modelList <- lapply(mtcars[-c(4,9)], function(x) aov(x ~ hp*am, data=mtcars) )
[2]
df2 <- plyr::ldply(modelList, function(x) summary(x)[[1]][["Pr(>F)"]])
names(df2) <- c(attr(modelList[[1]]$terms, "term.labels"), "residuals")
[3]
res.list <- lapply(modelList, '[[', "residuals")
par(mfrow=c(5,2), oma=c(0,0,0,0))
lapply(res.list, hist)