On Mon, 2005-01-10 at 14:52 +0000, Dan Bolser wrote: > 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).
OK. Then points 1 and 3 might be most helpful. One of the other things to consider, is that the legend() function can also be "tweaked" to create a multi-column table as an inset into an existing plot. As a very simplistic example: # Create a basic blank plot plot(1:60, type = "n") # Construct text for the table legend.txt <- as.matrix(as.data.frame(UCBAdmissions)) # Format the final column to have 2 decimal places # and have it be right justified legend.txt[, 4] <- format(as.numeric(legend.txt[, 4]), nsmall = 2) # Set a monospace font for table alignment par(family = "mono") # Plot the legend in 4 columns legend(1, 60, legend = legend.txt, ncol = 4) Take a look at ?legend and the various formatting functions. And....as Andy just mentioned in his reply, the textplot() function in the gplots package in the gregmisc bundle, which I always forget about... :-) HTH, Marc ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
