簡體   English   中英

使用R繪制具有標准錯誤的條形圖

[英]plotting barplots with standard errors using 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))

我真的很想克服這個問題!

謝謝,

巴茲

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
  )
)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM