Hi, I have a dynamic table structure consisting of N factors (e.g. columns Factor_1, Factor_2,..Factor_N). I want to construct a table that has as rows the level combinations of factors F_1..F_n-1, and as columns the levels of the factor Fn. The cells of the table would contain the number of cases that correspond to these level combinations. How can I do this? -- View this message in context: http://www.nabble.com/Interaction-of-a-dynamic-number-of-factors-tp23021835p23021835.html Sent from the R help mailing list archive at Nabble.com.
Try this:> ftable(CO2[1:3])Treatment nonchilled chilled Plant Type Qn1 Quebec 7 0 Mississippi 0 0 Qn2 Quebec 7 0 Mississippi 0 0 Qn3 Quebec 7 0 Mississippi 0 0 Qc1 Quebec 0 7 Mississippi 0 0 Qc3 Quebec 0 7 Mississippi 0 0 Qc2 Quebec 0 7 Mississippi 0 0 Mn3 Quebec 0 0 Mississippi 7 0 Mn2 Quebec 0 0 Mississippi 7 0 Mn1 Quebec 0 0 Mississippi 7 0 Mc2 Quebec 0 0 Mississippi 0 7 Mc3 Quebec 0 0 Mississippi 0 7 Mc1 Quebec 0 0 Mississippi 0 7>On Mon, Apr 13, 2009 at 8:39 AM, Nigel Birney <nan23 at cam.ac.uk> wrote:> > Hi, I have a dynamic table structure consisting of N factors (e.g. columns > Factor_1, Factor_2,..Factor_N). > > I want to construct a table that has as rows the level combinations of > factors F_1..F_n-1, and as columns the levels of the factor Fn. The cells of > the table would contain the number of cases that correspond to these level > combinations. How can I do this? > > -- > View this message in context: http://www.nabble.com/Interaction-of-a-dynamic-number-of-factors-tp23021835p23021835.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >
do you mean something like this: f1 <- gl(2, 2, length = 15) f2 <- gl(3, 2, length = 15) f3 <- gl(4, 2, length = 15) f4 <- gl(5, 2, length = 15) fcomb <- interaction(f1, f2, f3) table(fcomb, f4) I hope it helps. Best, Dimitris Nigel Birney wrote:> Hi, I have a dynamic table structure consisting of N factors (e.g. columns > Factor_1, Factor_2,..Factor_N). > > I want to construct a table that has as rows the level combinations of > factors F_1..F_n-1, and as columns the levels of the factor Fn. The cells of > the table would contain the number of cases that correspond to these level > combinations. How can I do this? >-- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014