[R] xyplot and lsegments

From: Alex Brown <fishtank_at_compsoc.man.ac.uk>
Date: Fri, 8 Feb 2008 15:36:25 +0000


Hi,

        How might I use xyplot to plot segments where the segments are in the input data? (ie a directed acyclic forest).

        Here's an example in base graphics:

n = data.frame(id = c(1,2,3,4), parent = c(0,1,2,2), value = c(5,5.5,7,3), date = c(1,2,3,3.5))

plot(n$date, n$value)

do.call(
  segments,
  with(
    merge(n,n,by.x="parent", by.y="id"),     data.frame(x0=date.x, y0=value.x, x1=date.y, y1=value.y)   )
)

        xyplot only seems to take an x and a y, and panels only seem to get x and y.

        I can see an lsegments, but I can't see how to use it in this example.

-Alex



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 08 Feb 2008 - 15:39:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 08 Feb 2008 - 18:30:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive