The 4 variables I have are: Breathless(B)= {y,n}, wheeze(W)= {y,n}, age={g1,g2,...,g5}, and count= {20 numeric counts}. I would like to construct a table as shown in the image, however the ftable function is unable to arrange the output properly into a table. How else can I construct it? Thanks in advance!
You can try to reshape your data using dcast
from data.table
library(data.table)
setDT(data)
dcast(data, age + Breathless ~ wheeze, value.var = "count")