删除 gtsummary 线性回归的 p 值列 table
Remove p-value column of gtsummary linear regression table
我正在使用 gtsummary 来总结我的线性回归结果。我试图省略每种性别的 p 值(列。
如有任何支持,我们将不胜感激。我已经包含了虚拟数据来重现我正在尝试做的事情,以及我的线性 reg table 的图像。
# 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
使用 modify_table_header()
函数,您可以在输出中选择 hide
列,包括 p-values:
tbl %>%
modify_table_header(
column = c(p.value_1, p.value_2),
hide = TRUE
)
祝你好运!
我正在使用 gtsummary 来总结我的线性回归结果。我试图省略每种性别的 p 值(列。
如有任何支持,我们将不胜感激。我已经包含了虚拟数据来重现我正在尝试做的事情,以及我的线性 reg table 的图像。
# 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
使用 modify_table_header()
函数,您可以在输出中选择 hide
列,包括 p-values:
tbl %>%
modify_table_header(
column = c(p.value_1, p.value_2),
hide = TRUE
)
祝你好运!