【发布时间】:2020-08-29 17:34:31
【问题描述】:
我正在使用 apistrat 数据创建一个汇总统计表,并将输出作为 R 中的表(希望最终使用 flextable 格式化)。我希望操纵表格,使每个变量的标准误差直接出现在我收集的平均值/中值下方。这是一个例子:
dstrata <- apistrat %>%
as_survey_design(strata = stype, weights = pw)
dstrata <- dstrata %>%
mutate(api_diff = api00 - api99)
dstrata %>%
summarise(api_diff = survey_mean(api_diff, vartype="se" ))
api_diff api_diff_se
<dbl> <dbl>
1 32.9 2.08
#so as you can see now, the standard error appears as its own column. Is there a way to reformat the table so it appears like this?
api_diff
<dbl>
1 32.9
(2.08)
一旦采用这种形式,我怎样才能将其转换为灵活表?每当我尝试这样做时,都会收到以下错误:
> table=flextable(dstrata)
Error in flextable(dstrata) : is.data.frame(data) is not TRUE
谢谢!
【问题讨论】:
标签: r datatable calculated-columns survey flextable