Hmisc icon indicating copy to clipboard operation
Hmisc copied to clipboard

Hmisc::wtd.table inconsistent with base::table for 0-count factor levels

Open jeffkeller-einc opened this issue 1 year ago • 0 comments

When tabulating factors (with or without weights), I noticed that wtd.table(..., type = "table") is not consistent with table from base R in the presence of factor levels without observations.

x <- factor(c("A", "B"), levels = c("A", "B", "C"))
table(x)
# A B C 
# 1 1 0 
Hmisc::wtd.table(x, type = "table")
# A B 
# 1 1 

Unless there is a specific reason for this, I think it would be best to remain consistent with table.

jeffkeller-einc avatar May 14 '24 22:05 jeffkeller-einc