使用R绘制具有标准错误的条形图 [英] plotting barplots with standard errors using R

查看:94
本文介绍了使用R绘制具有标准错误的条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绘制带有标准错误的简单条形图,这使我发疯.我确实查看了一些示例,并了解了以下内容:

I am trying to plot a simple barplot with standard errors and its driving me crazy. I did look up some examples and got as far as this:

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

我试图遍历脚本的最后一行,但是已经使用了很长时间了:

I am trying to get through the last line of script but have been on it for quite a while:

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

我真的很想克服这个问题!

I would really love to get over this one!

谢谢

巴兹

推荐答案

length是箭头的大小(错误栏的宽度): 45比您的情节大得多. 较小的值应该起作用.

length is the size of the arrow (the width of the error bar): 45 is much, much larger than your plot. A smaller value should work.

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

这篇关于使用R绘制具有标准错误的条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆