Re: [R] Problem with llines in lattice

From: John Fox <jfox_at_mcmaster.ca>
Date: Mon 31 Oct 2005 - 00:19:02 EST


Dear Deepayan,

The application in which I encountered the problem is much more complicated, so I'm not sure whether using groups will work there, but I'll give it a try.

Thanks for this,
 John

> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Deepayan Sarkar
> Sent: Saturday, October 29, 2005 6:01 PM
> To: John Fox
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] Problem with llines in lattice
>
> On 10/29/05, John Fox <jfox@mcmaster.ca> wrote:
> > Dear r-help list members,
> >
> > I'm experiencing problems getting type="b" (or "o" or "c")
> to work in
> > llines(). Try, e.g., the following scaled-down example:
> >
> > x <- factor(c("a", "b", "a", "b"))
> > y <- c(1,2,1,2)
> > z <- factor(c("A", "A", "B", "B"))
> > symbols <- 1:2
> > lines <- 1:2
> > colors <- 1:2
> > zvals <- levels(z)
> > xyplot(y~x|z, panel = function(x, y, subscripts, ...) {
> > for (i in 1:length(zvals)) {
> > sub <- z[subscripts] == zvals[i]
> > llines(x[sub], y[sub], lwd = 2, type = "b",
> > col = colors[i], pch = symbols[i], lty = lines[i])
> > }
> > })
> >
> > Only the lines (properly coloured with correct line types)
> appear, but
> > no symbols are plotted.
>
> It's bug in lplot.xy. Fortunately, panel.xyplot will do the
> same thing, so you can use it instead of llines.
>
> One comment: I'm not sure if this would work in your real
> application, but for your toy example a more direct approach would be
>
> xyplot(y ~ x | z, type = 'b', groups = z,
> col = colors, pch = symbols, lty = lines,
> lwd = 2)
>
> -Deepayan
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Oct 31 00:26:57 2005

This archive was generated by hypermail 2.1.8 : Mon 31 Oct 2005 - 03:42:14 EST