【问题标题】:Remove p-value column of gtsummary linear regression table删除 gtsummary 线性回归表的 p 值列
【发布时间】:2021-02-09 12:04:49
【问题描述】:

我正在使用 gtsummary 来总结我的线性回归结果。我试图省略每种性别的 p 值(列。

对此的任何支持将不胜感激。我已经包含了虚拟数据来重现我正在尝试做的事情,以及我的线性 reg 表的图像。

# install dev versions
remotes::install_github("ddsjoberg/gtsummary@mice_nnet")
remotes::install_github("larmarange/broom.helpers")

# load packages
library(gtsummary)
library(nnet)
theme_gtsummary_compact()

# dummy data 
crime <-data.frame(city = sample(c("SF", "AR", "NYC","MN"),13000,replace = TRUE),
                   sex = sample(c("Male", "Female"),13000,replace = TRUE),
                   year = sample(as.numeric(sample(10:20, 13000, replace = TRUE)))
                   )

# serperate data sets by sex
crime_f <- crime %>%
  filter(sex == "Female")
crime_m <- crime %>%
  filter(sex == "Male")

# build model for females
mod_f <- lm(year ~ city, data = crime_f) %>%
  tbl_regression(exponentiate = TRUE) %>%
  modify_header(estimate ~ "**OR**")

# build model for males
mod_m <- lm(year ~ city, data = crime_m) %>%
  tbl_regression(exponentiate = TRUE) %>%
  modify_header(estimate ~ "**OR**")


# lm model tabulated with gtsummary  
tbl <- tbl_merge(
  tbls = list(mod_f, mod_m),
  tab_spanner = c("**Female**", "**Male**")
  )

tbl # check table

【问题讨论】:

    标签: r gtsummary


    【解决方案1】:

    使用modify_table_header() 函数,您可以选择输出中的hide 列,包括p 值:

    tbl %>%
      modify_table_header(
        column = c(p.value_1, p.value_2),
        hide = TRUE
      )
    

    祝你好运!

    【讨论】: