[R] creating 3-way tables for mantelhaen.test

From: Taka Matzmoto <sell_mirage_ne_at_hotmail.com>
Date: Fri 17 Feb 2006 - 19:53:32 EST

Hi R users
I have serveral binary variables (e.g., X1, X2, X3, X4, X5, X,6, and X7) and one continuous variable (e.g., Y1).

I combined these variables using data.frame()

mydata <- data.frame(X1,X2,X3,X4,X5,X6,X7,Y1)

after that, I sorted this data.frame


after that, I replaced Y1's values with values ranging from 1 to 10 ( 1 represents the lowest group on Y1 and 10 presents the hight group on Y1). Now Y1 becomes a grouping variable.

What I like to do is to apply mantelhaen.test for each binary variable pair (e.g, X1 and X2, X1 and X3, X1 and X4, .... , X6 and X7)

In order to apply mantelhaen.test, a 3-dimensional contingency table is required.

Could you provide some advice on how to create a 3-dimensional contingency table (first dimension represents the first variable of variable pair, second dimension the second variable of variable pair, and third dimension represents 1 to 10 ) and apply mantelhaen.test ?

I looked at arrary, xtabs, table commands but I couldn't figure out yet.

Thank you

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Feb 17 20:00:51 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:33 EST