谢老师您好,我想请教一下,画lowess图的时候可以同时控制sampling weight吗?我使用的是survey数据,通过PPS进行取样,为了让sample更有代表性,我想使用sampling weight进行加权。(这个逻辑对吗?) 同时这个数据还提供weight with non-response adjustment,这个会对结果有什么影响吗?
谢谢!
谢谢!
新增ggplot2
实现:
library(easyGgplot2)
library(cowplot)
library(ggplot2)
data(PlantCounts,package = 'MSG')
g = ggplot(PlantCounts,
aes(altitude,counts)) +
geom_point(size=1.5,alpha=1/3) +
ylim(0,80)+
theme_bw()
for (i in seq(1,1000,10)){
col = rgb(0.4,i/1000,0.4)
g = g + stat_smooth(geom='line',
span=i/1000,
size=0.5,
se=F,color=col)
}
f = ggplot(PlantCounts,
aes(altitude, counts)) +
geom_point(size=1.5,alpha=1/3) +
ylim(0,80)+
theme_bw()
for (i in 1:200){
idx = sample(nrow(PlantCounts),300,T)
df = PlantCounts[idx,]
f = f + stat_smooth(geom='line',
data=df,
aes(altitude,counts),
span=1,size=0.5,
se=F,alpha=1/10)
}
# ggplot2.multiplot(g,f,cols=2)
plot_grid(g, f, ncol = 2)
songxiao 新增ggplot2实现:
easyGgplot2
似乎年久失修了,上次 commit 已经是接近三年前了:kassambara/easyGgplot2 。用 cowplot
之类的或许更好。其他代码不变,改最后一行为 cowplot::plot_grid(g, f, ncol = 2)
就行了。
获益匪浅,看完大神的介绍和评论对理解该方法又进了一步。感谢无私奉献!