Re: [R] recoding table dimensions interactively

2014-01-09 Thread Michael Friendly
Thanks for this, Bill Your solution does just what I want. In fact, it qualifies as the missing as.matrix() method for n-way tables arranged with ftable(), or vcd::structable(), which does provide an as.matrix() method, but omits the names and dimnames. Here it is, renamed and using "_" as t

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
Do you just want to change how the rows and columns of ftable's output are labelled? If so, the following may do what you want: it produces a matrix with dimnames based on the row.vars and col.vars attributes of ftable's output. f <- function(ftable) { makeDimNamesEl <- function(x) {