Re: [R] xtable with a table ?

About this list Date view Thread view Subject view Author view Attachment view

From: Gabor Grothendieck (ggrothendieck@myway.com)
Date: Wed 12 May 2004 - 01:48:19 EST


Message-id: <loom.20040511T174646-519@post.gmane.org>


t. <- table(a,b)
xtable(format(t.))

From: Ian Wilson <I.Wilson@maths.abdn.ac.uk>
:
: Any more elegant solutions to this?
:
: > a <- sample(c("a","d","c"),100,replace=T)
: > b <- sample(c("d","e","f",100,replace=T)
: > t <- table(a,b)
: > xtable(t)
: Error in xtable(t) : no applicable method for "xtable"
:
: The problem is that while t is a table (and
: hence also a matrix)
:
: > is.matrix(t)
: [1] TRUE
:
: data.frame(t) produces
:
: > data.frame(t)
: a b Freq
: 1 1 1 12
: 2 2 1 12
: 3 3 1 7
: 4 1 2 8
: 5 2 2 12
: 6 3 2 11
: 7 1 3 13
: 8 2 3 17
: 9 3 3 8
:
: After a horrible solution, I have
: ct <- apply(t,2,cbind);
: rownames(ct) <- rownames(t);
: xtable(ct)
:
: Is this a bug/feature, and if so how do I get round it?
:
: Ian Wilson
:

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:09 EST