[R] Need(?) way to create a "picture" (or "plot") of a data.frame
murdoch.duncan at gmail.com
Thu Jul 31 14:18:00 CEST 2014
On 31/07/2014, 8:06 AM, Duncan Murdoch wrote:
> On 31/07/2014, 7:49 AM, John McKown wrote:
>> OK, I'm probably using the wrong tool for this, but I'm doing
>> everything else in this project in R, so I'm looking at how to do this
>> too. I create a number of graphs using ggplot2. I use the png()
>> function before the print(..graph.variable..) in order to create a PNG
>> file which can be embedded in a MS PowerPoint display. This is working
>> fairly well.
>> But what I need now is a way to create a png file which is basically a
>> "picture" of what you might see when you simply display a data.frame
>> using Rstudio or even from the command prompt. I considered just using
>> sink() and print(), but I have two problems. First, it doesn't create
>> a PNG output. Second, I need to put in text annotations, title, etc.
>> So what I need might be what a "geom_data.table" would produce, if
>> such a thing existed in ggplot2.
>> Is there another "plotting" package which will do such a weird thing?
> One way is to use your OS to do a screen (or window) capture, and save
> the result to a .png file.
> There are also functions like textbox() in the plotrix package which
> allow you to display multiple lines of text; use capture.output() to
> save what was printed, then textbox() to add it to a plot.
A few more details: textbox normally wraps text, so use
lines <- paste(capture.output( ... ), "\n")
to get line breaks; you may want to set options("width") first; you may
want par(family="mono") first if you need character alignment.
More information about the R-help