我想不出如何给这个命名,我所拥有的是由这种形式的函数(特别是 midPci)生成的对象向量:
$conf.int
[1] 0.4726 0.6466
attr(,"conf.level")
[1] 0.95
$conf.int
[1] 0.1181 0.2566
attr(,"conf.level")
[1] 0.95
我想要做的是将 的两个值剥离$conf.int
成向量,给出上置信区间和下置信区间。显然我可以通过循环来做到这一点,但我认为可能有更好的方法来做到这一点?
CIs <- structure(list(conf.int = structure(c(0.4696, 0.6501), conf.level = 0.95),
conf.int = structure(c(0.5266, 0.7081), conf.level = 0.95), conf.int = structure(c(0.4441,
0.6196), conf.level = 0.95), conf.int = structure(c(0.4181, 0.5891), conf.level = 0.95),
conf.int = structure(c(0.4726, 0.6466), conf.level = 0.95), conf.int = structure(c(0.1181,
0.2566), conf.level = 0.95), conf.int = structure(c(0, 0.000748652688017826), conf.level =
0.95)), .Names = c("conf.int", "conf.int", "conf.int", "conf.int", "conf.int", "conf.int",
"conf.int" ))
如果不清楚我的意思,我已经这样做了:
# Calculate CIs
CIs <- mapply(midPci, k, n, conf.level=0.95)
我可以通过做CIs[1]$conf.int[1]
等来获得我所追求的个人价值观,但我想一口气把所有的东西都拿出来。我可以这样做吗?