transfer from old repo
This commit is contained in:
parent
cfa4a5f9cc
commit
277e2b8cf3
1111 changed files with 83736 additions and 0 deletions
59
1 PA Decline/grouped table rows.qmd
Normal file
59
1 PA Decline/grouped table rows.qmd
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
title: "nicer tables"
|
||||
format: docx
|
||||
editor: visual
|
||||
---
|
||||
|
||||
## Tables
|
||||
|
||||
```{r}
|
||||
library(gtsummary)
|
||||
library(dplyr)
|
||||
packageVersion("gtsummary")
|
||||
|
||||
trial%>%
|
||||
select(age, stage, grade)%>%
|
||||
tbl_summary()%>%
|
||||
modify_table_body(
|
||||
~.x %>%
|
||||
|
||||
# add your variable
|
||||
rbind(
|
||||
tibble(
|
||||
variable="Demographics",
|
||||
var_type=NA,
|
||||
var_label = "Demographics",
|
||||
row_type="label",
|
||||
label="Demographics",
|
||||
stat_0= NA))%>% # expand the components of the tibble as needed if you have more columns
|
||||
|
||||
# can add another one
|
||||
rbind(
|
||||
tibble(
|
||||
variable="Tumor characteristics",
|
||||
var_type=NA,
|
||||
var_label = "Tumor characteristics",
|
||||
row_type="label",
|
||||
label="Tumor characteristics",
|
||||
stat_0= NA))%>%
|
||||
|
||||
# specify the position you want these in
|
||||
|
||||
arrange(factor(variable, levels=c("Demographics",
|
||||
"age",
|
||||
"Tumor characteristics",
|
||||
"stage",
|
||||
"grade"))))%>%
|
||||
|
||||
# and you can then indent the actual variables
|
||||
modify_column_indent(columns=label, rows=variable%in%c("age",
|
||||
"stage",
|
||||
"grade"))%>%
|
||||
|
||||
# and double indent their levels
|
||||
modify_column_indent(columns=label, rows= (variable%in%c("stage",
|
||||
"grade")
|
||||
& row_type=="level"),
|
||||
double_indent=T)
|
||||
|
||||
```
|
||||
Loading…
Reference in a new issue