我有一个对象列表(Survey::svyciprop的输出),我正在try 提取它们的属性,以创建一个包含所有结果的数据框.
#example of an object
props_and_cis[[1]]
2.5% 97.5%
var1 0.932 0.826 0.98
我已经想好了如何在单独的专栏中提取我想要的每一项:
var <- attr(props_and_cis[[1]],"names")
prop <- as.vector(props_and_cis[[1]])
ci_lower <- attr(props_and_cis[[1]], "ci")[1]
ci_upper <- attr(props_and_cis[[1]], "ci")[2]
我想遍历我的列表props_and_cis
中的每个对象,并将提取的内容写入数据帧,例如:
tribble(
~variable, ~prop, ~ci_lower, ~ci_upper,
var,prop,ci_lower,ci_upper
)
但我似乎不能让它起作用.有人能帮帮忙吗?
预计到达时间:
> dput(props_and_cis[[1]])
structure(c(var1 = 0.932403111115339), var = structure(0.00119910004765771, dim = c(1L,
1L), dimnames = list("as.numeric(var1)", "as.numeric(var1)")), ci = c(`2.5%` = 0.825647967272783,
`97.5%` = 0.975715067477937), class = "svyciprop")