2
我想通過改變黃土平滑器的跨度參數來製作一個單面構圖(格子樣式)。我嘗試使用下面的for循環,但沒有生成劇情。如果我要使用ggsave函數,那麼繪圖會分開保存。方面ggplot通過黃土平滑器的跨度參數
此外,我想知道是否有更簡陋的方法來完成這樣的任務?
x <- rep(1:10,4)
y <- 1.2*x + rnorm(40,0,3)
s <- seq(0.2,0.8,0.1)
# plot the series of plots by varying the span parameter
for (s_i in s) {
qplot(x, y, geom = 'c('point','smooth'), span = s_i)
}
您還可以通過爲每個圖添加一個帶有跨度值的構麪條來模擬構面。例如(使用'ggplot'而不是'qplot'):'lapply(s,function(span){data.frame(dat,span = paste0(「Span =」,span)),aes(x, y))+ geom_point()+ geom_smooth(span = span)+ facet_grid(。〜span) })' – eipi10