[R] vectorized lines

Jim Brennan jfbrennan at rogers.com
Sun Aug 8 20:30:31 CEST 2004


abline(h=q) might be useful

Jim
----- Original Message -----
From: "Mikkel Grum" <mi2kelgrum at yahoo.com>
To: "RHelp" <r-help at stat.math.ethz.ch>
Sent: Sunday, August 08, 2004 1:26 PM
Subject: [R] vectorized lines


> Hi,
>
> I thought that the following code would give me a set
> of parallel lines on a plot as in the second example.
>
> q<-c(-2253,-2119,-1985,-1850)
> p<-c(1,2,3,4)
> a<-rep(min(p),4)
> b<-rep(max(p),4)
> plot(p,q)
>
> # example 1
> lines(c(a,b),c(q,q))
>
> Now this gives me the lines I really want:
>
> # example 2
> lines(c(a[1],b[1]),c(q[1],q[1]))
> lines(c(a[2],b[2]),c(q[2],q[2]))
> lines(c(a[3],b[3]),c(q[3],q[3]))
> lines(c(a[4],b[4]),c(q[4],q[4]))
>
> I assumed that example 1 was a shorter (vectorized)
> way of writing example 2?? What have I got wrong?
>
> cheers,
> Mikkel
>
> ______________________________________________
> 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