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
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
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) {
3 matches
Mail list logo