私のコードは9つの素敵な散布図を生成します。ただし、それらは奇妙な順序で出てきます(プロットする列のリストの一番下から始めて、一見右から左に見えます)。
プロットする順序を指定する方法はありますか?
私のコードは次のとおりです。
Z <- as.vector(as.matrix(sample_clean_data[, c("agri_dist", "allroads_dist", "DES_dist",
"elevation", "river_dist", "pop_dens",
"slope", "urban_dist", "LS_dist_to_edge")]))
Y10 <- rep(sample_clean_data$change, 9)
MyNames <- names(sample_clean_data[,c("agri_dist", "allroads_dist", "DES_dist",
"elevation", "river_dist", "pop_dens",
"slope", "urban_dist", "LS_dist_to_edge")])
ID10 <- rep(MyNames, each = length(sample_clean_data$change))
library(lattice)
ID11 <- factor(ID10, labels = c("Distance to nearest agriculture",
"Distance to nearest road",
"Distance to Dar es Salaam",
"Elevation (m)",
#"Distance to nearest main road",
"Distance to nearest major river",
"Population density (indiv./km2)",
"Slope",
"Distance to nearest urban centre",
"Landsat - Distance to forest edge"
),
levels = c("agri_dist", "allroads_dist", "DES_dist",
"elevation", "river_dist", "pop_dens",
"slope", "urban_dist", "LS_dist_to_edge"))
xyplot(Y10 ~ Z | ID11, col = 1,
strip = function(bg='white',...) strip.default(bg='white',...),
scales = list(alternating = F,
x = list(relation = "free"),
y = list(relation = "same")),
xlab = "Covariates",
par.strip.text = list(cex = 0.8),
ylab = "Change",
panel=function(x, y, subscripts,...){
panel.grid(h =- 1, v = 2)
panel.points(x, y, col = 1, pch = 16)
})
リストの一番上から入った順番で出てきて、左上隅からプロットすると思いました。