consider I have this sample data:
ID <- c(1:10)
group <- c("A","A","A","B","B","B","B","B","B","B")
condition_tall <- c(0,1,1,1,1,0,0,0,1,1)
condition_long <- c(1,1,1,1,0,0,0,1,1,1)
condition_wide <- c(1,1,0,0,0,1,1,1,1,0)
check_tall <- c(1,1,1,1,1,1,0,1,0,1)
check_long <- c(1,1,1,1,1,1,0,1,0,1)
check_wide <- c(1,1,0,1,0,1,0,1,0,1)
dat <- data.frame(ID,group,condition_tall,condition_long,condition_wide,check_tall,check_long,check_wide)
dat
What would the most efficient way bet o generate a summary table like this in R? I want the counts and percentages by group, for "condition" and "check." Thank you so much.
| Group A | Group B | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Variable | Condition (N) | Condition (%) | Check (N) | Check (%) | Condition (N) | Condition (%) | Check (N) | Check (%) | |
| tall | |||||||||
| long | |||||||||
| wide | |||||||||