I'm trying to make a table that evaluates two variables, like the one below:
  Diabetes No_Diabetes
1        0          12
2        5         234
3        7         182
4        3          57
By using table(x), I can get these frequencies for each individual column (in this example, Diabetes or No_Diabetes):
table(data$bmi_cat[DIABETES==0])
  1   2   3   4 
 12 234 182  57 
table(data$bmi_cat[DIABETES==1])
2 3 4 
5 7 3 
but because 1 = 0 in this example, when I try to put the two tables into one data frame, I receive an error message that states they cannot be combined because they are different lengths.
I succumbed to using for loops to make the original data frame above, but there has to be an easier way than writing 8 separate loops when "table" does this so efficiently. Any suggestions on how to combine the two tables, perhaps by finding a way to display 1 = 0 in the second table? Thanks!!!
 
    