移除gtsummary线性回归表的p值列

时间:2020-10-27 08:25:26

标签: r gtsummary

我正在使用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

enter image description here

1 个答案:

答案 0 :(得分:3)

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

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

enter image description here

祝你好运!