1
for 루프에서 여러 개의 격자 플롯을 생성하려고하지만 빈 이미지를 생성합니다 !!!for 루프 - 빈 이미지가 생성되었습니다
for (f in unique(df$month)) {
plot.new()
bwplot(x ~ country|type, data = df[df$month == f,], panel=function(...) {
panel.abline(h=0, col="green")
panel.bwplot(...)
})
savePlot(paste0("file_", f), "png")
}
for 루프의 내부를 "손으로"실행하면 작동하지만 루프에서 작동이 중지됩니다. 왜?
set.seed(123)
n <- 300
country <- sample(c("Europe", "Africa", "Asia", "Australia"), n, replace = TRUE)
type <- sample(c("city", "river", "village"), n, replace = TRUE)
month <- sample(c("may", "june", "july"), n, replace = TRUE)
x <- rnorm(n)
df <- data.frame(x, country, type, month)
Aaaaaargh! 얼마나 contventuitive R! 고마워, 나는이 접근법을 보았지만'savePlot'과는 달리 동시에 그 그림을 보여주지는 않을 것이다. – TMS