R语言使用一键输出表格方法

library(pacman)
plan1$ITEM_NAME
pacman::p_load(tableone) 
table1 <- CreateTableOne(vars = ecls_cov, data = plan1, strata = 'ITEM_NAME') 
table1 <- print(table1, printToggle = FALSE, noSpaces = TRUE) 
knitr::kable(table1[,1:3], align = 'c', caption = 'Comparison of unmatched samples') 

 

#按CRvsnonCR疗效分组对比各变量
library(pacman)
vars = names(mydata[,-c(25,26,28)])
factorVars = names(mydata[,-c(2,25,26,27,28)])
pacman::p_load(tableone) 
table1 <- CreateTableOne(vars = vars, factorVars = factorVars,data = mydata, strata = 'CRvsnonCR') 
table1 <- print(table1, printToggle = FALSE, noSpaces = TRUE) 
knitr::kable(table1[,1:3], align = 'c', caption = 'Comparison of unmatched samples') 
 

你可能感兴趣的:(R语言使用一键输出表格方法)