2012-03-16 57 views
1

我想繪製一個簡單的標準錯誤的barplot,它使我瘋狂。我也看一些例子和得到儘可能的:使用R繪製標準錯誤的污跡圖

rt5 <- data.frame(rtgrp=c(37.2,38.0,38.3,38.5,38.9), 
mort=c(35,11,16,8,4), 
se=c(0.08,0.01,0.005,0.01,0.02)) 
rt5 
xvals=with(rt5, 
barplot(mort,names.arg=rtgrp, 
xlab="PTEMP_R group mean",ylab="%",ylim=c(0,max(mort+10+se)))) 

我想通過腳本的最後一行,但還是一直在這相當長的一段:

with(rt5, 
arrows(xvals,mort,xvals,mort+se,length=45,angle=90,code=3)) 

我會真的很喜歡克服這一點!

謝謝,

巴茲

+1

'barplot2'從'gplots'包 - 而且谷歌「炸藥陰謀」 – 2012-03-16 13:31:55

回答

3

length是箭頭(誤差條的寬度)的大小: 45多,比你的積大得多。 應該使用較小的值。

with(rt5, 
    arrows(
    xvals,mort,xvals,mort+se, 
    length=.3, angle=90, code=3, 
    # Change the colour and line width, to see the error bars 
    col="navy", lwd=5 
) 
) 
+0

非常感謝! – baz 2012-03-17 04:18:45