微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何重新排列 gtsummary 或 flextable 中的列?

如何解决如何重新排列 gtsummary 或 flextable 中的列?

关于这个答案[置信区间] (https://stackoverflow.com/a/66891473/13734451), 如何重新排列 gtsummary 或 flextable 中的列?有一种方法可以使用 gt 包(如下所示)来做到这一点,但这不会与 Word 女士结合。有线索吗?

final_tbl %>% as_gt() %>%
  cols_move(
    columns = vars(Male_ci),after = vars(stat_1)
  )

解决方法

这是一个移动 gtsummary 对象列的示例。此脚本将 p.value 列移到 label 列之后

library(gtsummary)
packageVersion("gtsummary")
#> '1.4.0'

# build table
tbl <-
  trial %>%
  select(age,trt) %>%
  tbl_summary(by = trt,missing = "no") %>%
  add_p() 

# move p.value column
tbl %>%
  modify_table_body(~.x %>% dplyr::relocate(p.value,.after = label))

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。