Good Morning,
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.
1 2 3 <space> 10 11 12 <space> 19 20 21
4 5 6 <space> 13 14 15 <space> 22 23 24
7 8 9 <space> 16 17 18 <space> 25 26 27
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.
Is there any other way of doing it.
Minimal Dataset (sample.txt):
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
R Script,
library(car)
sampledata <- read.table("H:/sample.txt", header=TRUE)
y.1 <- sampledata$Y1
y.2 <- log(sampledata$Y2)
y.3 <- sqrt(sampledata$Y3)
x.1 <- sampledata$X
x.2 <- (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)
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.
Plot 1 - Plot 9
Plot 10 - Plot 18
Plot 19 - Plot 27
Appreciate if you could give me a headup on this.