Note that there are some explanatory texts on larger screens.

plurals
  1. POR: multiplot not working because of error in UseMethod("getModelInfo",model)
    text
    copied!<p>In R, I have prepared multiple <code>ggplot2</code> figures, that are saved to variables like this:</p> <pre class="lang-js prettyprint-override"><code>flashplot &lt;- ggplot(flash, aes(x=flash$Year, y=flash$Proc)) + stat_smooth(method="lm", formula = "flash$Proc ~ poly(flash$Year, 2, raw=TRUE)", n=14, level=0.9) + geom_point(shape=19) + ylab("Percentage of total existing versions") + xlab("Years of Existence") + scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16,18,20)) </code></pre> <p>plotting a single figure works as expected, but I want to plot 4 figures (2 by 2) using multiplot, as described <a href="http://wiki.stdout.org/rcookbook/Graphs/Multiple%20graphs%20on%20one%20page%20%28ggplot2%29/" rel="nofollow">in the R cookbook</a>.</p> <p>As I got an error, I tried the example from the cookbook, which I thould would work, but it gave me the same error:</p> <pre><code>&gt; multiplot(p1, p2, p3, p4, cols=2) Error in UseMethod("getModelInfo", model) : no applicable method for 'getModelInfo' applied to an object of class "c('gg', 'ggplot')" </code></pre> <p>I am using R 2.15.2 under Windows 7, and the newest packages of <code>ggplot2</code> and <code>coefplot</code>:</p> <pre><code>&gt; sessionInfo() R version 2.15.2 (2012-10-26) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=German_Austria.1252 LC_CTYPE=German_Austria.1252 [3] LC_MONETARY=German_Austria.1252 LC_NUMERIC=C [5] LC_TIME=German_Austria.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] coefplot_1.1.8 ggplot2_0.9.3 loaded via a namespace (and not attached): [1] colorspace_1.2-0 dichromat_1.2-4 digest_0.6.0 grid_2.15.2 [5] gtable_0.1.2 labeling_0.1 MASS_7.3-22 munsell_0.4 [9] plyr_1.8 proto_0.3-9.2 RColorBrewer_1.0-5 reshape2_1.2.2 [13] scales_0.2.3 stringr_0.6.2 useful_1.1.6 </code></pre> <p>any hints to help me solving my problem would be highly appreciated. Am I missing something? I already searched the web, but found nothing helpful</p> <p>-- As requested, here is the example data:</p> <pre><code>library(ggplot2) # This example uses the ChickWeight dataset, which comes with ggplot2 # First plot p1 &lt;- ggplot(ChickWeight, aes(x=Time, y=weight, colour=Diet, group=Chick)) + geom_line() + ggtitle("Growth curve for individual chicks") # Second plot p2 &lt;- ggplot(ChickWeight, aes(x=Time, y=weight, colour=Diet)) + geom_point(alpha=.3) + geom_smooth(alpha=.2, size=1) + ggtitle("Fitted growth curve per diet") # Third plot p3 &lt;- ggplot(subset(ChickWeight, Time==21), aes(x=weight, colour=Diet)) + geom_density() + ggtitle("Final weight, by diet") # Fourth plot p4 &lt;- ggplot(subset(ChickWeight, Time==21), aes(x=weight, fill=Diet)) + geom_histogram(colour="black", binwidth=50) + facet_grid(Diet ~ .) + ggtitle("Final weight, by diet") + theme(legend.position="none") # No legend (redundant in this graph) multiplot(p1, p2, p3, p4, cols=2) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload