为什么我的table条目的分数在我的意外事件table中除以四?

Why are the fractions of my table entries divided by four in my contingency table?

这是我的应急措施tablecxTable:

                Always Wrong Almst Always Wrg Sometimes Wrong Not Wrong At All
  Lower Class           1344              166             146               73
  Working Class        11997             1775            1105              355
  Middle Class         11221             2320            1188              341
  Upper Class            696              177             125               47 

添加边距效果很好:

> marginCxTable = addmargins(cxTable)
> marginCxTable

                Always Wrong Almst Always Wrg Sometimes Wrong Not Wrong At All   Sum
  Lower Class           1344              166             146               73  1729
  Working Class        11997             1775            1105              355 15232
  Middle Class         11221             2320            1188              341 15070
  Upper Class            696              177             125               47  1045
  Sum                  25258             4438            2564              816 33076

但是加上分数我的总和只有 25% 而不是 100%。所有其他条目也除以四。

> prop.table(marginCxTable)

                Always Wrong Almst Always Wrg Sometimes Wrong Not Wrong At All          Sum
  Lower Class   0.0101584230     0.0012546862    0.0011035192     0.0005517596 0.0130683880
  Working Class 0.0906775305     0.0134160721    0.0083519773     0.0026832144 0.1151287943
  Middle Class  0.0848122506     0.0175353731    0.0089793204     0.0025773975 0.1139043415
  Upper Class   0.0052606119     0.0013378280    0.0009447938     0.0003552425 0.0078984762
  Sum           0.1909088161     0.0335439594    0.0193796106     0.0061676140 0.2500000000

我可能漏掉了一些非常简单的东西。谢谢你的帮助。

根据@joran 的评论,您想在 addmargins() 之前执行 prop.table()。使用 mtcars 数据进行说明,以便其他人可以重现输出:

mt <- table(mtcars$cyl, mtcars$am)
addmargins(prop.table(mt))
#           0       1     Sum
# 4   0.09375 0.25000 0.34375
# 6   0.12500 0.09375 0.21875
# 8   0.37500 0.06250 0.43750
# Sum 0.59375 0.40625 1.00000