[R] vectorized lines
Uwe Ligges
ligges at statistik.uni-dortmund.de
Sun Aug 8 19:51:35 CEST 2004
Mikkel Grum wrote:
> 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?
See ?segments
Uwe Ligges
> 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