[R] Displaying Counts of Unused Factors in Contingency Tables with table()

Na'im R. Tyson ntyson at clovermail.net
Thu Jul 29 07:29:24 CEST 2010


R-philes,

I have a question about displaying counts of unused factors using the  
table() function.  I have two vectors with character data in them:

local.labels("ah", "ah", "ah~")
local.preds("ah", "ah", "ah")

If I use the table function as shown below, I get an error because the  
number of levels do not match up.

v.cont.table <- table(local.labels, local.preds, dnn=c("observed",  
"predicted"));

Is there any way to get zero counts into the contingency table, or  
would I have to use a flat table?  Any help with sample code, or a  
pointer to a previous post, would be much appreciated.

Regards,

Na'im



More information about the R-help mailing list