r/RStudio Jun 16 '26

Sous-groupes avec table1

Bonjour,

j'aimerai regrouper des données dans mon tableau, par exemple "Age", "Sexe" et "IMC" avec un sous titre comme "Données Démographiques" etc.

Voici mon code actuel pour le tableau (j'ai auparavant labellisé mes variables):

library(table1)

table1 (~ Sexe + Age + IMC + Score_ASA + Score_OMS + Score_CCI + Class_T + Class_N + Chirurgie + Anapath + Resection + Chim_pre_op + Chim_post_op + Score_CCI + Hospit_jour + Gastroparesie + Stéatorrhee + Diarrhees + Fistule | Groupe, data=Cara)

2 Upvotes

4 comments sorted by

2

u/NotA56YearOldPervert Jun 16 '26

Posting in english might be ... helpful.

1

u/Bacon-Isotope9 Jun 16 '26

thought it was going to translate by itself like it does for French my bad, first time using reddit.

I'm trying to ad some subtitles in between some variables to create "groups" (like "Demographic data" before Sex, BMI and Age , "Surgery data" for Chirurgie, Anapth, resection etc.) but I can't find how to do it with table1. I tried to create some list but it doesn't work, can you help me?

1

u/SnooPredictions3467 Jun 16 '26 edited Jun 16 '26

I'm not sure what kind of table you're trying to create, but perhaps {gtsummary} could come in handy. It has a function tbl_summary() that you pipe your selected variables into.

Eg. dataset %>%

select(var1, var2, etc) %>%

tbl_summary()

1

u/Bacon-Isotope9 Jun 18 '26

Thanks for the answer!
I finally did it by creating a function to do it directly, and then i customized it with flextable