Re: [R] inside a function & other glitches

From: Michael Hopkins <>
Date: Wed, 02 Jul 2008 13:16:59 +0100

Thanks to all who replied on list and to me directly.

You are right, FAQ 7.22 is the answer. For any others who get caught by this it's important to print(..) a plot with a function, not just create it, i.e.

        print( xyplot(... ) )

not just

        xyplot(... )

..otherwise it doesn't necessarily get sent to the opened device.


On 2 Jul 2008, at 01:06, Deepayan Sarkar wrote:

> On 7/1/08, Michael Hopkins <>
> wrote:
>> Hi R people
>> I am using a function to create a pdf device, then send a lot of
>> plots
>> to it in a loop then a last lattice xyplot (itself within a function)
>> outside the loop and finally call to write to the file.
>> This works well apart from the fact that the last plot does not get
>> sent to the file unless I comment out and then apply it in
>> the console afterwards instead:
>> plot_stuff( ...);
>> The device is opened like this:
>> pdf( paste( var_string, ".pdf", sep="" ), onefile=TRUE,
>> paper="a4r",
>> width=9, height=6.5 )
>> Also, if I try to send two different xyplots after the loop only the
>> last one ever gets written to the file, whether or not I apply the
>> trick above.
>> Any thoughts on why this stuff happens and best ways to avoid it are
>> appreciated.
> This sounds like FAQ 7.22:
> The issue is most likely a red herring; the important bit is
> that the xyplot() call was not the last expression in your function.
> -Deepayan

                          Office:    +44 (O)1732 228844
                          Mobile:    +44 (O)7813 467381

______________________________________________ mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Wed 02 Jul 2008 - 12:31:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jul 2008 - 13:31:54 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive