【发布时间】:2023-07-26 21:25:02
【问题描述】:
我想要做的是为比例的上下置信区间设置列。
这是我所做的:
> #Create some sample data
> Frustration <- data.table(group = c('A','B','C'), trials = c(363,1398,139), surg = c(57,276,18))
> Frustration
group trials surg
1: A 363 57
2: B 1398 276
3: C 139 18
>
> #try to get confidence levels. what I am expecting is CI to be a list of 2 elements, for each value of group, but I don't think that is working
> F2 <- Frustration[, .(CI = prop.test(surg, trials, conf.level = .75)['conf.int']), by = .(group)]
> F2
group CI
1: A 0.1350140,0.1816828
2: B 0.1851178,0.2103210
3: C 0.09701967,0.16972056
>
> #lower is still a list here - I am stumped
> F3 <- F2[, .(lower = CI[[1]]), by = .(group)]
> F3
group lower
1: A 0.1350140,0.1816828
2: B 0.1851178,0.2103210
3: C 0.09701967,0.16972056
我认为混淆与列表有关,以及数据表如何处理返回。
感谢您的帮助,
大卫
【问题讨论】:
标签: r data.table confidence-interval