我需要在 by() 中更改 t.test 中的置信度值
res<-by(HUS[,1], HUS$air.conditioning, FUN=t.test)
我在哪里可以提供 conf.level?
uj5u.com熱心網友回復:
使用匿名/lamdba 函式(function(x)
res <- by(HUS[,1], HUS$air.conditioning, FUN =
function(x) t.test(x, conf.level = 0.90))
或指定命名引數
res <- by(HUS[,1], HUS$air.conditioning, FUN=t.test, conf.level = 0.90)
注意:指定命名引數可能不適用于所有函式,例如 ave
檢查可重現的示例
res1 <- by(mtcars[, "mpg"], mtcars$cyl, FUN = t.test, conf.level = 0.90)
res2 <- by(mtcars[, "mpg"], mtcars$cyl, FUN = function(x) t.test(x, conf.level = 0.90))
> res1 <- lapply(res1, function(x) {x$data.name <- "x"; x})
> all.equal(res1, res2, check.attributes = FALSE)
[1] TRUE
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/318519.html
