繁体   English   中英

tbl_summary 错误:dims [产品 18] 与 object [27] 的长度不匹配

[英]tbl_summary error: dims [product 18] do not match the length of object [27]

我试图在数据帧上运行 tbl_summary 并在 add_overall() function 中的 pipe 时不断收到此错误。 我在其他数据帧的代码中的其他地方使用了这两个函数,但没有收到错误。

我的资料

我的代码:

select(adverseAll, c(supplement, event, grade, attribution, duration2, outcome)) %>%
    tbl_summary(by = supplement, statistic = list(c(duration2) ~ "{mean} ({sd})"),
                digits = list(c(duration2) ~ 2),
                label = list(event ~ "Adverse Effect", grade ~ "Severity", attribution ~ "Attribution", duration2 ~ "Duration", outcome ~ "Outcome")
  ) %>%
  modify_spanning_header(c("stat_1", "stat_2") ~ "**Supplement**") %>%
   add_overall(last = TRUE)

确切的错误:

Error in attributes(vec) <- attributes(x$meta_data$df_stats[[which(x$meta_data$variable %in%  : 
  dims [product 18] do not match the length of object [27]

当我删除 add_overall() function 时,output 看起来像这样: Output 没有整体列

我尝试删除 NA 值并使用因子和字符数据类型。 任何帮助,将不胜感激!

我能够通过导出 dataframe 并重新读取它,然后使用新的 df 运行 tbl_summary 来修复它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM