【问题标题】:tbl_regression sample size in model - gtsummary模型中的 tbl_regression 样本大小 - gtsummary
【发布时间】:2021-02-15 05:28:54
【问题描述】:

有没有办法在 tbl_regression 输出中添加样本大小。 是指用于模型的实际样本?

#example
tbl_regression(model, exponentiate = TRUE)

谢谢,

#gtsummary

【问题讨论】:

    标签: gtsummary


    【解决方案1】:

    有两种方法可以将模型 N 添加到 tbl_regression() 表中。

    1. 使用modify_header() 将N 包含在列标题中。需要 gtsummary v1.3.6 或更高版本。
    2. 使用add_n() 向表中添加包含观察数的列。需要 gtsummary 的当前开发版本。使用remotes::install_github("ddsjoberg/gtsummary") 安装开发版
    library(gtsummary)
    packageVersion("gtsummary")
    #> '1.3.6.9013'
    
    glm(response ~ age, trial, family = binomial) %>%
      tbl_regression(exponentiate = TRUE) %>%
      modify_header(label ~ "**Characteristic, N = {N}**") %>% # Add N to the column header
      add_n() %>%                                              # Add N column to table
      add_nevent()                                             # Add Event N column to table
    

    【讨论】:

    • 非常感谢丹尼尔!,第一种方法有效,尽管下载和更新了整个包,但第二种方法给了我以下错误: UseMethod("add_n") 中的错误:'add_n 没有适用的方法' 应用于类“c('tbl_regression', 'gtsummary')”的对象这是我的输入tbl_regression(model, exponentiate = TRUE)%>% modify_header(label ~ "**Characteristic, N = {N}**") %>% add_n() %>% add_nevent() 感谢您的帮助,
    • 你用遥控器安装了吗::install_github("ddsjoberg/gtsummary") ?
    • 我能够下载并运行它。使用上面的代码后,我收到以下错误:Error in eval(parse(text = text, keep.source = FALSE), envir) : object 'N' not found In addition: Warning messages: 1: In tcm * w : longer object length is not a multiple of shorter object length 2: In tcm * y * w : longer object length is not a multiple of shorter object length 3: In y * w : longer object length is not a multiple of shorter object length
    • 请发表一个代表
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-14
    • 1970-01-01
    • 2022-01-21
    • 1970-01-01
    • 2021-07-07
    • 1970-01-01
    相关资源
    最近更新 更多