[R] dev.new() within a loop

Giovanni Azua bravegag at gmail.com
Sun Nov 13 15:35:24 CET 2011


On Nov 13, 2011, at 3:23 PM, David Winsemius wrote:
>>> Please read both my comments and the FAQ more carefully . You are inadequately considering the information that has been offered to you.
>>> 
>> Ok you wanted to make sure I have to read the FAQ well I didn't have to :) Googling using your suggestion found relevant matches and now it works.
> 
> Where does this resistance to reading the FAQ come from?

It is not resistance, the FAQ is very helpful for basic general questions but it can not cover all details. Sometimes it is very hard to find a specific detailed answer within a general FAQ. I have read the FAQ, what makes you think I didn't before? I just could not find the information I was looking for.


>> I had to wrap the ggplot call within a "print" for my loop to work which is IMHO one of the most obfuscated use-cases for using print I have bumped into.
> 
> It is a case of isolating the functional aspects of the plot-construction process from the side-effects of interacting with a graphics device.
> 
>> So every user-defined function that try to plot anything has to be wrapped inside a print just in case it ever gets called from within a loop
> 
> That is not how I understand it. One reason is so there is an object in the workspace that can be later modified. And I suspect the authors (and I am not one of them)  imagined that there may be multiple steps in creation of the  object, not all of which should result in a plot appearing if this is being done programatically. This is especially appropriate (it would seem to me) for the ggplot plotting model, which adds a variety of layers to a core object. It is also imagined that you may be sending this object to one of a variety of devices.
> 
Ok bottom line is always wrap the plot call whatever it is within a print for the just in case.

Cheers,
Giovanni



More information about the R-help mailing list