Re: [R] xtable with a table ?

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

From: Peter Dalgaard (p.dalgaard@biostat.ku.dk)
Date: Wed 12 May 2004 - 01:08:22 EST


Message-id: <x265b33st5.fsf@biostat.ku.dk>


"Ian Wilson" <I.Wilson@maths.abdn.ac.uk> writes:

> 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"

Others might get a different error:

> xtable(t)
Error: couldn't find function "xtable"
> library(xtable)
Error in library(xtable) : There is no package called 'xtable'

I.e. do remember to say when you're using a contributed package (and
also which version)

> 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?

I got away with

 xtable(unclass(tb))

but of course there ought to be an xtable.table method. You still lose
the dimname-names though.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

______________________________________________ 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