[R] plot(x,y) with errors

Spencer Graves spencer.graves at pdf.com
Wed Mar 3 11:06:41 CET 2004


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




More information about the R-help mailing list