[R] drc, ggplot2, and gridExtra

Eivind K. Dovik he||o @end|ng |rom e|v|nddov|k@com
Fri May 18 18:56:54 CEST 2018


On Fri, 18 May 2018, Ed Siefker wrote:

> I have dose response data I have analyzed with the 'drc' package.
> Using plot() works great.  I want to arrange my plots and source
> data on a single page.  I think 'gridExtra' is the usual package for
> this.
>
> I could use plot() and par(mfrow=...), but then I can't put the source
> data table on the page.
>
> gridExtra provides grid.table() which makes nice graphical tables. It
> doesn't work with par(mfrow=...), but has the function grid.arrange()
> instead.
>
> Unfortunately, grid.arrange() doesn't accept plot(). It does work with
> qplot() from 'ggplot2'.  Unfortunately, qplot() doesn't know how to
> deal with data of class drc.
>
> I'm at a loss on how to proceed here.  Any thoughts?
>

Hi,

If you grab the plots as grobs, you can arrange them using grid.arrange()

library(gridGraphics)
library(gridExtra)

grab <- function{
 	grid.echo()
 	grid.grab()
}

x <- rnorm(100, 1, 2)
y <- rnorm(100, 0, 0.5)

plot(x,y)
p <- grab()

a <- rnorm(20, 0, 1)
b <- rnorm(20, 1, 2)

plot(a, b)
q <- grab()

grid.arrange(p, q)


Best,
Eivind K. Dovik
Bergen, NO


> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>




More information about the R-help mailing list