0

Hi i want to make a contingency table but with more than 2 variables This is the example that i'm looking for : variable example (die, age cat, glucose score) Thank you so much for your future advice

           Age cat (n)  Glucose score
Die   |     18        | 2.24               |                  
No die|   20          | 3.31
mumber1
  • 15
  • 4
  • 1
    [See here](https://stackoverflow.com/q/5963269/5325862) on making a reproducible example that is easier for folks to help with. What have you tried that didn't work? It's unclear what we're looking at and how this is a contingency table exactly – camille Dec 02 '22 at 03:16
  • If you have a data frame with those columns and use `library(dplyr)`, something like `your_data %>% group_by(die) %>% summarize(across(c(glucose_score, age_cat), mean))`. – Gregor Thomas Dec 02 '22 at 03:56
  • @GregorThomas Thanks this code works but i don't want the mean for people who die by each Age cat, i just want the number but for the glucose score i want mean. Do you know how can i do ? thank you – mumber1 Dec 02 '22 at 18:39
  • Finnaly i found it your_data %>% group_by(age cat,die) %>% summarize(across(c(glucose, summary)) thank you so much – mumber1 Dec 02 '22 at 19:03
  • Glad you found it! Next time I'd suggest sharing a little bit of sample input as well as the desired output so we can understand better what you want to do and what you're working with. – Gregor Thomas Dec 02 '22 at 19:21

0 Answers0