Re: [R] recoding table dimensions interactively

2014-01-09 Thread Michael Friendly
Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Friendly Sent: Thursday, January 09, 2014 7:14 AM To: R-help Subject: [R] recoding table dimensions interactively Given a 3+ way table, I'd like

Re: [R] recoding table dimensions interactively

2014-01-09 Thread Hadley Wickham
Hi Michael, It's pretty easy with reshape: library(reshape2) ucbm <- melt(UCBAdmissions) acast(ucbm, Admit + Gender ~ Dept) acast(ucbm, Admit ~ Dept + Gender) acast(ucbm, Admit + Dept + Gender ~ .) # You can also do aggregations acast(ucbm, Admit ~ Dept, fun = sum) Hadley On Thu, Jan 9, 2014 a

Re: [R] recoding table dimensions interactively

2014-01-09 Thread William Dunlap
re, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Michael Friendly > Sent: Thursday, January 09, 2014 7:14 AM > To: R-help > Subject: [R] recoding table dimensions int

[R] recoding table dimensions interactively

2014-01-09 Thread Michael Friendly
Given a 3+ way table, I'd like a simple, elegant way to flatten the table to a two-way table, with some variables joined interactively to form the rows and others forming the columns. For example, starting with > str(UCBAdmissions) table [1:2, 1:2, 1:6] 512 313 89 19 353 207 17 8 120 205 ...