I'm struggling to figure out how to create the following table;
using the following dataset
```{r}
df<-data.frame(ID=c(1,2,3,4,5,6),
Treat_Cont = c("Treatment", "Treatment", "Treatment", "Control", "Control", "Control"),
Q1 = c("Yes", "No", NA, "Yes", "No", NA),
Q2 = c("Yes", "No", NA, "Yes", "No", NA)
)
```
The main problem I have had using table()
, the expss
package or tables
package is that they treat each level of the factor seperately, so the table will produce a count, for example, for; Treat_Control == Treatment & Q1 == Yes & Q2 == Yes
.
Currently, I am at a stage where I'm unsure whether my issue is one of data structure, meaning I should reshape my dataset, or whether I'm missing a function or an argument to achieve this result.
Thanks,