[R] is.matrix(), as.matrix, & as(,"matrix")
Gabor Grothendieck
ggrothendieck at myway.com
Mon Feb 21 02:02:49 CET 2005
John Maindonald <john.maindonald <at> anu.edu.au> writes:
: I often want to use xtable() with tables. There is no method
: defined for the class "table". After a bit of rummaging, I found
: that I can use:
: xtable(as(tab, "matrix")).
That's probably ok for most practical purposes but it will
not preserve the table's dnn, if it has one:
R> tab <- table(1:3, dnn = "A")
R> tab # dnn present
A
1 2 3
1 1 1
R> as.matrix(tab) # dnn gone
[,1]
1 1
2 1
3 1
More information about the R-help
mailing list