Yes of course (why didn't you yourself read the man/help pages? That's the way 
I learned R).

If you see the help to grid.arrange:

arrangeGrob             package:gridExtra              R Documentation

arrangeGrob

Description:

     arrange ggplot2, lattice, and grobs on a page

Usage:

       arrangeGrob(..., as.table = FALSE, clip = TRUE,
         main = NULL, sub = NULL, left = NULL, legend = NULL)

Arguments:

     ...: plots of class ggplot2, trellis, or grobs, and valid
          arguments to grid.layout


For the ellipses:

The arguments to to grid.layout is your savior:

(here is the help to grid.layout):


grid.layout                package:grid                R Documentation

Create a Grid Layout

Description:

     This function returns a Grid layout, which describes a subdivision
     of a rectangular region.

Usage:

     grid.layout(nrow = 1, ncol = 1,
             widths = unit(rep(1, ncol), "null"),
             heights = unit(rep(1, nrow), "null"),
             default.units = "null", respect = FALSE,
             just="centre")

Arguments:

    nrow: An integer describing the number of rows in the layout.


And then for the call to do.call

do.call                  package:base                  R Documentation

Execute a Function Call

Description:

     'do.call' constructs and executes a function call from a name or a
     function and a list of arguments to be passed to it.

Usage:

     do.call(what, args, quote = FALSE, envir = parent.frame())

Arguments:

    what: either a function or a non-empty character string naming the
          function to be called.

    args: a _list_ of arguments to the function call.  The 'names'
          attribute of 'args' gives the argument names.


The args argument saves you:

This suggests me to do:


lattice.plots <- list(xyplot(rnorm(10) ~ 1:10, type = "b"),
                                     xyplot(rnorm(10) ~ 1:10, type = "b"),
                                     xyplot(rnorm(10) ~ 1:10, type = "b"),
                                     xyplot(rnorm(10) ~ 1:10, type = "b"))

do.call(grid.arrange, list(lattice.plots, ncol = 1))

That does NOT WORK, damn someone, even though the help to do.call says that 
args should be a _list_ (damn you isn't that a LIST)

However this works:

do.call(grid.arrange,c(lattice.plots, ncol = 1))


WHAT IS THE DIFFERNCE BETWEEN c() and list()????????????????

Have a nice day to all of you.

And thank you all developers for R. I cannot live without it.


Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling

Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
fr...@vestas.com<mailto:fr...@vestas.com>
http://www.vestas.com<http://www.vestas.com/>

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice<http://www.vestas.com/legal/notice>
If you have received this e-mail in error please contact the sender.

From: Santosh [mailto:santosh2...@gmail.com]
Sent: 18. februar 2014 20:59
To: Frede Aakmann Tøgersen
Cc: r-help
Subject: Re: [R] plot a list of trellis objects

Thanks for the suggestion..
Is there a way I can include arguments to the grid.arrange function?

I tried in your example something like...
gridar <- function(x,ncol=2,...) grid.arrange(x,...)
do.call(gridar, lattice.plots);

I could not make it work when I try to control number of columns/rows and have 
multiple pages the way possible using print.trellis

Regards,
Santosh

On Mon, Feb 17, 2014 at 10:38 PM, Frede Aakmann Tøgersen 
<fr...@vestas.com<mailto:fr...@vestas.com>> wrote:
How about


lattice.plots <- list(xyplot(rnorm(10) ~ 1:10, type = "b"),
                                     xyplot(rnorm(10) ~ 1:10, type = "b"),
                                     xyplot(rnorm(10) ~ 1:10, type = "b"),
                                    xyplot(rnorm(10) ~ 1:10, type = "b"))

do.call(grid.arrange, lattice.plots)

There is most likely a loop hidden somewhere in the do.call function ;-)


Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling

Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
fr...@vestas.com<mailto:fr...@vestas.com>
http://www.vestas.com

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice<http://www.vestas.com/legal/notice>
If you have received this e-mail in error please contact the sender.

> -----Original Message-----
> From: r-help-boun...@r-project.org<mailto:r-help-boun...@r-project.org> 
> [mailto:r-help-boun...@r-project.org<mailto:r-help-boun...@r-project.org>]
> On Behalf Of Santosh
> Sent: 18. februar 2014 01:41
> To: r-help
> Subject: [R] plot a list of trellis objects
>
> Dear Rxperts
>
> Is there a way to control the display order (or simplistically control
> panel layout) of a list of trellis objects without using a for loop (or
> whatever)?
>
> I just realize that gridExtra has that feature.. (grid.arrange)...
>
> But, converting each of those elements of the list of trellis objects into
> an argument to grid.arrange seems to negate the simplicity.. In addition,
> if I were to use grid.arrange on a list of trellis objects, is there a way
> to pass the list elements as arguments to grid.arrange?
>
> If you have other suggestions, please do..
>
> Regards,
> Santosh
>
>       [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org<mailto:R-help@r-project.org> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to