I would like R to produce some tabulated data in a graphical output. When I say tabulated data, what I mean is a table with rows and columns. This would be useful when reading in a big file, performing some analysis on it, and then wanting to display the results as a table. Something like plot(x,...) where x is a matrix For example, the result could look (approximatly) like... +-------+-----------+ | A | B | +-------+-----------+ | 1 | 33278 | | 2 | 6790 | ... | 10 | 1 | | 12 | 6 | +-------+-----------+ I havent (and cant) see any way to do this. Is there currently any way to do this? I imagine it could be put together with various other plotting 'fundamentals', but the syntax of the layout format could be a pain to get right. OK, I just found xtable (Export tables to LaTeX or HTML). Any plans to make a print.xtable(x,type="X",...) or print.xtable(x,type="png",...) function? Any easy way to convert a latex table to an image without actually doing latex latex.table.file.tex dvi2png latex.table.file.dvi ? Cheers, Dan.
On Mon, 2005-01-10 at 11:05 +0000, Dan Bolser wrote:> I would like R to produce some tabulated data in a graphical output. When > I say tabulated data, what I mean is a table with rows and columns. This > would be useful when reading in a big file, performing some analysis on > it, and then wanting to display the results as a table. > > Something like > > plot(x,...) > > where x is a matrix > > For example, the result could look (approximatly) like... > > +-------+-----------+ > | A | B | > +-------+-----------+ > | 1 | 33278 | > | 2 | 6790 | > ... > | 10 | 1 | > | 12 | 6 | > +-------+-----------+ > > > I havent (and cant) see any way to do this. Is there currently any way to > do this? I imagine it could be put together with various other plotting > 'fundamentals', but the syntax of the layout format could be a pain to get > right. > > OK, I just found xtable (Export tables to LaTeX or HTML). Any plans to > make a print.xtable(x,type="X",...) or print.xtable(x,type="png",...) function? > > Any easy way to convert a latex table to an image without actually doing > > latex latex.table.file.tex > > dvi2png latex.table.file.dvi > > ?It is not entirely clear what you want to do with the table once you have created it. That piece of information might be helpful in attempting to offer some ideas. In lieu of that, here are some additional pointers: 1. Review the output and code for: demo(plotmath) 2. Review the latex() and html() functions in Frank Harrell's Hmisc package, which provide additional functionality along with xtable(). 3. Review these two posts regarding a general approach to plotting tables: http://tolstoy.newcastle.edu.au/R/help/02b/0345.html http://tolstoy.newcastle.edu.au/R/help/02b/0342.html HTH, Marc Schwartz
I recall there's a function in the gregmisc bundle that can write text to an R plot (was it textplot?). That might be of use here, I guess. Andy> From: Dan Bolser > > On Mon, 10 Jan 2005, Marc Schwartz wrote: > > >On Mon, 2005-01-10 at 11:05 +0000, Dan Bolser wrote: > >> I would like R to produce some tabulated data in a > graphical output. When > >> I say tabulated data, what I mean is a table with rows and > columns. This > >> would be useful when reading in a big file, performing > some analysis on > >> it, and then wanting to display the results as a table. > >> > >> Something like > >> > >> plot(x,...) > >> > >> where x is a matrix > >> > >> For example, the result could look (approximatly) like... > >> > >> +-------+-----------+ > >> | A | B | > >> +-------+-----------+ > >> | 1 | 33278 | > >> | 2 | 6790 | > >> ... > >> | 10 | 1 | > >> | 12 | 6 | > >> +-------+-----------+ > >> > >> > >> I havent (and cant) see any way to do this. Is there > currently any way to > >> do this? I imagine it could be put together with various > other plotting > >> 'fundamentals', but the syntax of the layout format could > be a pain to get > >> right. > >> > >> OK, I just found xtable (Export tables to LaTeX or HTML). > Any plans to > >> make a print.xtable(x,type="X",...) or > print.xtable(x,type="png",...) function? > >> > >> Any easy way to convert a latex table to an image without > actually doing > >> > >> latex latex.table.file.tex > >> > >> dvi2png latex.table.file.dvi > >> > >> ? > > > >It is not entirely clear what you want to do with the table once you > >have created it. That piece of information might be helpful in > >attempting to offer some ideas. > > > >In lieu of that, here are some additional pointers: > > > >1. Review the output and code for: > > > >demo(plotmath) > > > > > >2. Review the latex() and html() functions in Frank Harrell's Hmisc > >package, which provide additional functionality along with xtable(). > > > > > >3. Review these two posts regarding a general approach to plotting > >tables: > > > >http://tolstoy.newcastle.edu.au/R/help/02b/0345.html > >http://tolstoy.newcastle.edu.au/R/help/02b/0342.html > > Thanks very much. > > I want either an image of a table, or to include a table in > an existing > plot (i.e. to supplement a plot). > > > > > > > > > >HTH, > > > >Marc Schwartz > > > > > > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >
Well I saw the title "graphical table..." and had just a cursory glance However I do use this function which is good if not too many categories are represented. Anne ----- Original Message ----- From: "Marc Schwartz" <MSchwartz at MedAnalytics.com> To: "Anne" <anne.piotet at urbanet.ch> Sent: Monday, January 10, 2005 5:54 PM Subject: Re: [R] Graphical table in R> On Mon, 2005-01-10 at 17:14 +0100, Anne wrote: > > symbol.freq in Hmisc > > > > Anne > > Hi Anne, > > Thanks for pointing that out, though that function is really a graphical > representation of a contingency table. It does not print out summary > details, etc. which is what I believe that Dan is looking for. > > Thanks, > > Marc > >
The outer two lines could also be done more easily (?) by: library(gplots) #part of gregmisc bundle textplot(txt) Check ?textplot for additional options. Andy __________________________________ Andy Jaworski 518-1-01 Process Laboratory 3M Corporate Research Laboratory ----- E-mail: apjaworski at mmm.com Tel: (651) 733-6092 Fax: (651) 736-3122 Thomas Lumley <tlumley at u.washin gton.edu> To Sent by: Peter Dalgaard r-help-bounces at st <p.dalgaard at biostat.ku.dk> at.math.ethz.ch cc MSchwartz at medanalytics.com, R list <r-help at stat.math.ethz.ch> 01/10/2005 03:28 Subject PM Re: [R] Graphical table in R On Mon, 10 Jan 2005, Peter Dalgaard wrote:> A screen shot of a ps file? That sounds ... weird. If you can view it, > presumably you have Ghostscript and that can do png files. > > However, will textual output do? > > plot(0,type="n",axes=FALSE, xlab="", ylab="") > con <- textConnection("txt","w") > sink(con); ftable(UCBAdmissions); sink() > close(con) > par(family="mono") > text(1,0,paste(txt,collapse="\n")) >and the middle three lines could also be done with txt<-capture.output(ftable(UCBAdmissions)) -thomas ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html