[R] Contingency tables as data frames
Kurt.Hornik at ci.tuwien.ac.at
Mon Mar 6 17:58:57 CET 2000
>>>>> presnell writes:
> I'm teaching a categorical data analysis course this term, and a minor
> "problem" has resurfaced that I have often thought about before. This
> applies equally to Splus I suppose, but my undergrads aren't using
> It seems natural to read/represent a contingency table as a data
> frame, with one column representing the cell counts (as in the example
> appended below (data taken from Agresti, "An Introduction to
> Categorical Data Analysis"). However, functions like ftable,
> mantelhaen.test, chisq.test, fisher.test, etc. don't work naturally
> with this representation, and instead require the user to first
> manipulate the data, say by using tapply to convert the data into an
> array. This is not difficult of course, but it's one of those things
> that I'd rather not have to explain to students, who usually need to
> be focusing on other things.
> So, am I missing something obvious (not unlikely), or would it be a
> good idea to extend the methods/arguments of these functions to
> analyze/manipulate data represented in this way without any
> preprocessing by the user? It seems that a "count" (or "weight" or
> "freq" or whatever) argument would do it in most cases.
> Funny, I can't help but wonder if the answer from those who have
> thought about this more deeply than I have might be "it's a can of
Very good idea.
I think that S-PLUS crosstabs() can do that.
Let me think some more about this ...
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help