Let say i have
But, I want to have the final output something like:
So, i want to "automatically" generate for any value aa with zero frequency, i want to add the missing value of aa and its zero frequency into the table. So, i dont have to manually type and check this step again and again whenever i change the value of aa. Simply say, i want to add those missing line in table_aa generated by table(aa).
P/S: Actually table_aa is just a frequency table of aa which can be obtained using table(aa). But, as an example here, i simply set their values.
Code:
aa=c(0,2,3,5)
freq=c(13,4,5,2)
table_aa=cbind(aa,freq)
Code:
table_aa
aa freq
0 13
[COLOR="red"]1 0[/COLOR]
2 4
3 5
[COLOR="red"]4 0[/COLOR]
5 2
P/S: Actually table_aa is just a frequency table of aa which can be obtained using table(aa). But, as an example here, i simply set their values.