0
在link第一張圖顯示了這裏的如何可視化標準錯誤,我想複製一個非常好的例子,在R.如何複製描述R中平均值標準誤差的圖形?
我用下面的
set.seed(1)
pop<-rnorm(1000,175,10)
mean(pop)
hist(pop)
#-------------------------------------------
# Plotting Standard Error for small Samples
#-------------------------------------------
smallSample <- replicate(10,sample(pop,3,replace=TRUE)) ; smallSample
smallMeans<-colMeans(smallSample)
par(mfrow=c(1,2))
x<-c(1:10)
plot(x,smallMeans,ylab="",xlab = "",pch=16,ylim = c(150,200))
abline(h=mean(pop))
#-------------------------------------------
# Plotting Standard Error for Large Samples
#-------------------------------------------
largeSample <- replicate(10,sample(pop,20,replace=TRUE))
largeMeans<-colMeans(largeSample)
x<-c(1:10)
plot(x,largeMeans,ylab="",xlab = "",pch=16,ylim = c(150,200))
abline(h=mean(pop))
但我到達那裏我不知道如何繪製原始數據,因爲它們與X符號一樣。謝謝。
嘗試使用'ggplot2'軟件包。基本的是'ggplot(data.frame(x,smallMeans),aes(x = x,y = smallMeans))+ geom_point()+ geom_line()+ geom_hline(yintercept = mean(pop))' – Sotos
感謝你的迴應。這接近我迄今爲止所做的(請參閱更新的代碼),但我希望能夠覆蓋原始數據點 –