Skip to content
Prev 139011 / 398506 Next

question for crosstable

eugen pircalabelu wrote:
Is this what you want?

 > CrossTable(xtabs(c ~ a + d, z), format = "SPSS", asresid = TRUE)

    Cell Contents
|-------------------------|
|                   Count |
| Chi-square contribution |
|             Row Percent |
|          Column Percent |
|           Total Percent |
|           Adj Std Resid |
|-------------------------|

Total Observations in Table:  24

              | d
            a |        a  |        b  |        c  | Row Total |
-------------|-----------|-----------|-----------|-----------|
            1 |        7  |        5  |        3  |       15  |
              |    0.336  |    0.417  |    1.225  |           |
              |   46.667% |   33.333% |   20.000% |   62.500% |
              |   77.778% |   83.333% |   33.333% |           |
              |   29.167% |   20.833% |   12.500% |           |
              |    1.198  |    1.217  |   -2.286  |           |
-------------|-----------|-----------|-----------|-----------|
            2 |        2  |        1  |        0  |        3  |
              |    0.681  |    0.083  |    1.125  |           |
              |   66.667% |   33.333% |    0.000% |   12.500% |
              |   22.222% |   16.667% |    0.000% |           |
              |    8.333% |    4.167% |    0.000% |           |
              |    1.116  |    0.356  |   -1.434  |           |
-------------|-----------|-----------|-----------|-----------|
            3 |        0  |        0  |        6  |        6  |
              |    2.250  |    1.500  |    6.250  |           |
              |    0.000% |    0.000% |  100.000% |   25.000% |
              |    0.000% |    0.000% |   66.667% |           |
              |    0.000% |    0.000% |   25.000% |           |
              |   -2.191  |   -1.633  |    3.651  |           |
-------------|-----------|-----------|-----------|-----------|
Column Total |        9  |        6  |        9  |       24  |
              |   37.500% |   25.000% |   37.500% |           |
-------------|-----------|-----------|-----------|-----------|


Note that the first argument to CrossTable(), 'x', can be either a 
vector or a matrix, the latter if 'y' is unspecified.

HTH,

Marc Schwartz