Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sorting a table for latex output with xtable

Tags:

r

xtable

I´m trying to produce a sorted table and export in to latex. However it seems xtable cannot cope with sorted tables. Suggestions?

   a<-sample(letters,500,replace=T)
    b<-table(a)
    c<-sort(table(a),decreasing=T)
    xtable(b)
    xtable(c)

//M

like image 293
Misha Avatar asked Sep 07 '10 18:09

Misha


1 Answers

Pretty easy: sort() does not return a table, but an array. Use as.table() to solve your problem :

a<-sample(letters,500,replace=T)
b<-table(a)
class(b)
c<-sort(table(a),decreasing=T)
class(c)
d <- as.table(c)
class(d)
xtable(d)
like image 82
Joris Meys Avatar answered Oct 04 '22 20:10

Joris Meys