简体   繁体   中英

Arrow function not plotting error bars on basic R scatter plot

I've found some resources on stack to add error bars to a basic scatter plot, however when I input it the bars do not show up on the graph.

my data frame is as follows:

Year<-c(2018,2019,2020,2021)
RI<-c(0.0006018311, 0.0007092285, 0.0011958185, 0.0008217980)
sdev<-c(0.001490281, 0.001316973, 0.002424346, 0.001562423)

RIplot<-plot(Year,RI,xaxt="n",ylim=range(c(RI-sdev,RI+sdev)),pch=19, xlab="Year", ylab="Mean Residency Index +/- Std. Dev")

axis(1, at=seq(2018,2021,by=1), las=2)

I get the following graph: 在此处输入图像描述

when I try to addthe error bars like so:

arrows(x0=x,y0=RI-sdev,x1=x,y1=RI+sdev, length=0.1, angle=90, code=3)

Nothing shows up on the graph!

Thank you!

Never-mind--> realized my x value of Year was input as a character and not numerical, once i fixed that everything went smoothly!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM