Note that there are some explanatory texts on larger screens.

plurals
  1. PONested Plots in R
    primarykey
    data
    text
    <p>Good Morning,</p> <p>I am trying to create 1 x 3 plot where each of the individual plot itself a combine plots of 3 x 3. The number below represent the individual plot ID.</p> <pre><code>1 2 3 &lt;space&gt; 10 11 12 &lt;space&gt; 19 20 21 4 5 6 &lt;space&gt; 13 14 15 &lt;space&gt; 22 23 24 7 8 9 &lt;space&gt; 16 17 18 &lt;space&gt; 25 26 27 </code></pre> <p>Tried using par, and layout. It is not coming out well as all the 3 plots coming out individually and not nested. Perhaps I have confused myself. </p> <p>Is there any other way of doing it.</p> <p>Minimal Dataset (sample.txt):</p> <pre><code>X Y1 Y2 Y3 277 5.20 3.16 5.92 285 5.17 3.14 5.89 297 4.96 2.97 5.70 308 5.26 3.21 5.97 308 5.11 3.09 5.84 263 5.27 3.22 5.98 278 5.20 3.16 5.92 283 5.16 3.13 5.88 268 5.17 3.14 5.89 250 5.20 3.16 5.92 275 5.18 3.15 5.90 274 5.09 3.07 5.82 312 5.03 3.02 5.77 294 5.21 3.17 5.93 279 5.29 3.24 6.00 300 5.14 3.11 5.86 293 5.09 3.07 5.82 298 5.16 3.13 5.88 290 4.99 2.99 5.73 273 5.23 3.19 5.95 289 5.32 3.26 6.03 279 5.21 3.17 5.93 326 5.14 3.11 5.86 293 5.22 3.18 5.94 256 5.15 3.12 5.87 291 5.09 3.07 5.82 283 5.09 3.07 5.82 284 5.07 3.06 5.80 298 5.27 3.22 5.98 269 5.19 3.15 5.91 </code></pre> <p>R Script,</p> <pre><code>library(car) sampledata &lt;- read.table("H:/sample.txt", header=TRUE) y.1 &lt;- sampledata$Y1 y.2 &lt;- log(sampledata$Y2) y.3 &lt;- sqrt(sampledata$Y3) x.1 &lt;- sampledata$X x.2 &lt;- (sampledata$X)^2 par(mfrow=c(1,3)) par(mfrow=c(3,3)) leveragePlots(lm(y.1 ~ x.1)) leveragePlots(lm(y.1 ~ x.1)) leveragePlots(lm(y.1 ~ x.1)) leveragePlots(lm(y.1 ~ x.1)) leveragePlots(lm(y.1 ~ x.1)) leveragePlots(lm(y.1 ~ x.1)) leveragePlots(lm(y.1 ~ x.1)) leveragePlots(lm(y.1 ~ x.1 + x.2), layout = NA) title("Plot 1 - Plot 9", outer=TRUE, line =-2) par(mfrow=c(3,3)) leveragePlots(lm(y.2 ~ x.1)) leveragePlots(lm(y.2 ~ x.1)) leveragePlots(lm(y.2 ~ x.1)) leveragePlots(lm(y.2 ~ x.1)) leveragePlots(lm(y.2 ~ x.1)) leveragePlots(lm(y.2 ~ x.1)) leveragePlots(lm(y.2 ~ x.1)) leveragePlots(lm(y.2 ~ x.1 + x.2), layout = NA) title("Plot 10 - Plot 18", outer=TRUE, line =-2) par(mfrow=c(3,3)) leveragePlots(lm(y.3 ~ x.1)) leveragePlots(lm(y.3 ~ x.1)) leveragePlots(lm(y.3 ~ x.1)) leveragePlots(lm(y.3 ~ x.1)) leveragePlots(lm(y.3 ~ x.1)) leveragePlots(lm(y.3 ~ x.1)) leveragePlots(lm(y.3 ~ x.1)) leveragePlots(lm(y.3 ~ x.1 + x.2), layout = NA) title("Plot 19 - Plot 27", outer=TRUE, line =-2) </code></pre> <p>Unfortunately the above produces, 3 different, 3x3 plots as shown below, whereas all the 27 plots need to be position as the map given in the first paragraph.</p> <p><img src="https://i.stack.imgur.com/bEm2t.png" alt="Plot 1 - Plot 9"> Plot 1 - Plot 9</p> <p><img src="https://i.stack.imgur.com/GcTb9.png" alt="Plot 10 - Plot 18"> Plot 10 - Plot 18</p> <p><img src="https://i.stack.imgur.com/LENaT.png" alt="Plot 19 - Plot 27"> Plot 19 - Plot 27</p> <p>Appreciate if you could give me a headup on this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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