Thank you.
I actually ended up using:

> CrossTable(mdt)

   Cell Contents
|-------------------------|
|                       N |
| Chi-square contribution |
|           N / Row Total |
|           N / Col Total |
|         N / Table Total |
|-------------------------|


Total Observations in Table:  8


             |
             |      Blue |     Green |       Red | Row Total |
-------------|-----------|-----------|-----------|-----------|
           A |         1 |         0 |         1 |         2 |
             |     0.083 |     0.500 |     0.083 |           |
             |     0.500 |     0.000 |     0.500 |     0.250 |
             |     0.333 |     0.000 |     0.333 |           |
             |     0.125 |     0.000 |     0.125 |           |
-------------|-----------|-----------|-----------|-----------|
           G |         1 |         0 |         1 |         2 |
             |     0.083 |     0.500 |     0.083 |           |
             |     0.500 |     0.000 |     0.500 |     0.250 |
             |     0.333 |     0.000 |     0.333 |           |
             |     0.125 |     0.000 |     0.125 |           |
-------------|-----------|-----------|-----------|-----------|
           H |         1 |         0 |         1 |         2 |
             |     0.083 |     0.500 |     0.083 |           |
             |     0.500 |     0.000 |     0.500 |     0.250 |
             |     0.333 |     0.000 |     0.333 |           |
             |     0.125 |     0.000 |     0.125 |           |
-------------|-----------|-----------|-----------|-----------|
           W |         0 |         2 |         0 |         2 |
             |     0.750 |     4.500 |     0.750 |           |
             |     0.000 |     1.000 |     0.000 |     0.250 |
             |     0.000 |     1.000 |     0.000 |           |
             |     0.000 |     0.250 |     0.000 |           |
-------------|-----------|-----------|-----------|-----------|
Column Total |         3 |         2 |         3 |         8 |
             |     0.375 |     0.250 |     0.375 |           |
-------------|-----------|-----------|-----------|-----------|


and

> expected.counts <- (apply(mdt,1,sum) %o% apply(mdt,2,sum))/sum(mdt)

> print(expected.counts)

  Blue Green  Red

A 0.75   0.5 0.75

G 0.75   0.5 0.75

H 0.75   0.5 0.75

W 0.75   0.5 0.75
to get the info I needed.


Regards,
Joanna

On Mon, Mar 4, 2013 at 2:15 PM, Milan Bouchet-Valat <nalimi...@club.fr>wrote:

> Le lundi 04 mars 2013 à 12:37 -0600, Joanna Papakonstantinou a écrit :
> > I am trying to create contingency tables (to evaluate prior to performing
> > Pearson's Chi-Squared test for independence). I would like to see column
> > and row totals as well as expected and observed values and cell counts.
> > I tried to use the package "contingency. tables" but get the following
> > warning:
> >  package contingency.tables is not available (for R versions 2.15.2)
> > Is there something comparable or was this replaced with something else
> for
> > later versions of R.
> > Any help would be appreciated so that I may create a contigencey table
> like
> > this.
> I'm not aware of the existence of such a package, but base R provides
> most of what you need, and other packages offer even more. See e.g.
> http://www.statmethods.net/stats/frequencies.html
>
>
> Regards
>



-- 
******************************************************************


*Joanna Papakonstantinou, Ph.D.*

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to