Dear all, I have 2 variables, x<-c(1,2,3,4,5,6,7,8,9,10) y<-c(1.3,2.5,4.6,5.3,5.9,6.7,7.4,8.5,9.4,10.4) each point of the y variable has an error: erry<-(0.2,0.3,0.2,0.1,0.4,0.2,0.3,0.4,0.3,0.2) how to plot(x,y) with the errors segments? Thank you, Copex --------------------------------- [[alternative HTML version deleted]]
Does the following do what you want: > x<-c(1,2,3,4,5,6,7,8,9,10) > y<-c(1.3,2.5,4.6,5.3,5.9,6.7,7.4,8.5,9.4,10.4) > erry<-c(0.2,0.3,0.2,0.1,0.4,0.2,0.3,0.4,0.3,0.2) > > plot(x, y) > > n <- length(x) > Y <- array(c(y-erry, y+erry), dim=c(n,2)) > for(i in 1:n) + lines(rep(x[i],2), Y[i,]) Others may have more elegant solutions, but this is simple enough for me to understand AND produces essentially the same result in R 1.8.1 and S-Plus 6.2. hope this helps. spencer graves Fulvio Copex wrote:>Dear all, >I have 2 variables, >x<-c(1,2,3,4,5,6,7,8,9,10) >y<-c(1.3,2.5,4.6,5.3,5.9,6.7,7.4,8.5,9.4,10.4) >each point of the y variable has an error: >erry<-(0.2,0.3,0.2,0.1,0.4,0.2,0.3,0.4,0.3,0.2) >how to plot(x,y) with the errors segments? >Thank you, >Copex > > > > >--------------------------------- > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >
Fulvio Copex wrote:> Dear all, > I have 2 variables, > x<-c(1,2,3,4,5,6,7,8,9,10) > y<-c(1.3,2.5,4.6,5.3,5.9,6.7,7.4,8.5,9.4,10.4) > each point of the y variable has an error: > erry<-(0.2,0.3,0.2,0.1,0.4,0.2,0.3,0.4,0.3,0.2) > how to plot(x,y) with the errors segments? > Thank you, > CopexSee ?segments. Are the errors intended to be mean-centered ??? Uwe Ligges> > > > --------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
see plotCI in package gregmisc --- Date: 03 Mar 2004 12:00:12 +0100 From: Peter Dalgaard <p.dalgaard at biostat.ku.dk> To: Spencer Graves <spencer.graves at pdf.com> Cc: <r-help at stat.math.ethz.ch> Subject: Re: [R] plot(x,y) with errors [...] I think there are special "plot with errorbars" in some of the "misc" packages on CRAN