我正在创建一个描述性统计表(代码如下),该表继续为Mar
变量生成以下错误,该变量表示五个级别的婚姻状况(“单身”,“已婚”,“分居/离婚”,“丧偶”和“其他”):Warning for variable 'Mar': simpleWarning in stats::chisq.test(x = structure(c(1L, 1L, 2L, 1L, 2L, 2L, 1L, : Chi-squared approximation may be incorrect Error in s$close() : attempt to apply non-function
table_desc <- analytical %>%
tbl_summary(
include = -id,
by = exposure,
statistic = list(all_continuous() ~ "{mean} ({sd})",
all_categorical() ~ "{n} ({p}%)"),
label = list(SexF ~ "Sex",
Race ~ "Race",
Mar ~ "Marital Status",
AGE ~ "Age",
PROBLEMUse ~ "Substance Problem Use",
EDUCATION ~ "Education Level",
EMPLOYMENT ~ "Employment"),
) %>%
add_overall() %>%
bold_labels() %>%
add_p(test = list(all_continuous() ~ "kruskal.test",
all_categorical() ~ "chisq.test")) %>%
bold_p() %>%
as_gt() %>%
gtsave(
filename = "~/tables/Table_X.png"
)
这个错误意味着什么,它的解决方案是什么?
1条答案
按热度按时间cwxwcias1#
事实证明,
Mar
变量的“其他”水平的观察结果太少,无法正确地进行跨组比较(在exposure
变量的一个或两个水平中,没有参与者支持“其他”类别)。将此类别与“寡妇”类别聚合解决了这个问题!