I have a matrix such as:
> mt <- matrix(1:9, nrow=3, ncol=3)
> dimnames(mt) <- list( c('a','b','c'), c('x','y','z') )
> mt
  x y z
a 1 4 7
b 2 5 8
c 3 6 9
I can convert it into a tabular format with:
> as.data.frame(as.table(mt))
  Var1 Var2 Freq
1    a    x    1
2    b    x    2
3    c    x    3
4    a    y    4
5    b    y    5
6    c    y    6
7    a    z    7
8    b    z    8
9    c    z    9
My question is - Is there a clean way to do the reverse?
 
     
     
    