Good Morning,
Am new to R. I am trying to combine 9 plots, arranging it to 3 x 3.
I have a) 7 leveragePlots() syntax that creates 1 plot each,and b) the 8th leveragePlots() generates 2 plots as it is two variable linear model fit.
When using the below, the first 7 plots where arranged well, but the last one does not fit into the 3x3 grid but opens a new window with 2 plots.
Minimal Dataset (sample.txt):
X Y
276.67 5.20
285.00 5.17
296.67 4.96
307.50 5.26
307.50 5.11
262.50 5.27
278.33 5.20
282.50 5.16
267.50 5.17
250.00 5.20
275.00 5.18
274.17 5.09
311.67 5.03
294.17 5.21
279.17 5.29
300.00 5.14
292.50 5.09
297.50 5.16
290.00 4.99
272.50 5.23
289.17 5.32
279.17 5.21
325.83 5.14
292.50 5.22
255.83 5.15
290.83 5.09
283.33 5.09
284.17 5.07
298.33 5.27
269.17 5.19
Tried using par(mfrow=c(3,3)) and also layout(matrix(c(1,2,3,4,5,6,7,8,8), 3, 3, byrow = TRUE)). It is not working. Still opening new window for the last syntax of leveragePlots(). To replicate the codes are below,
library(car)
sampledata <- read.table("D:/sample.txt", header=TRUE)
y.1 <- sampledata$Y
x.1 <- sampledata$X
x.2 <- (sampledata$X)^2
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))
Do you know how I can force the final 2 plots to be placed in the same 3x3 layout? If you do, please advice me.
Am currently reading on layout() at http://rfunction.com/archives/1538 ,not sure how to use this to achieve the above.
Thanks for your lead.