[R] xyplot question

hadley wickham h.wickham at gmail.com
Sat Sep 15 00:49:57 CEST 2007


Hi Raymond,

It isn't lattice, but this is fairly easy to do with ggplot2:

install.packages("ggplot2")
library(ggplot2)

qplot(x, y, facets = group ~ Method) +
geom_linerange(aes(min = lcl, max=ucl)) +
geom_abline()

See more at http://had.co.nz/ggplot2

Hadley

On 9/14/07, Raymond Balise <iteachtyping at gmail.com> wrote:
> I am tring to do an xyplot where I want to plot 5 dots in each pane of
> the trellice and the dots need to have lines (whiskers) extending up
> and down at each point(plus a 45 degree reference line).  The data
> frame is set up with the variables x y lcl and ucl (where the lcl and
> ucl are the limits on the lines I want).  The code below gives me the
> points but I cant figure out the lines limited by the lcl and ucl
> variable.
>
>
> library(lattice)
> library(grid)
>
> with(fig2,
>           xyplot(y ~ x |  group * Method,
>           xlab = "",
>           xlim = c(-5, 1),
>           ylab = "",
>           ylim = c(-5, 1),
>           col = "black",
>           groups = group,
>           aspect = 1,
>
>           panel = function(x, y, ...) {
>              panel.superpose(x, y, ...)
>              panel.abline(0, 1)
>          },
>          )
> )
>
> The not trellice version of the first image I need in the xyplot can
> be done like this:
>
> with(sub1,
> plot(y~x,
>           xlim = c(-5,1),
>           ylim = c(-5,1)
>           )
> )
> abline (0, 1)
> lines(rep(sub1$x[1],2), c(sub1$lcl[1], sub1$ucl[5]))
> lines(rep(sub1$x[2],2), c(sub1$lcl[2], sub1$ucl[5]))
> lines(rep(sub1$x[3],2), c(sub1$lcl[3], sub1$ucl[5]))
> lines(rep(sub1$x[4],2), c(sub1$lcl[4], sub1$ucl[5]))
> lines(rep(sub1$x[5],2), c(sub1$lcl[5], sub1$ucl[5]))
>
> How can i tell it to use the lcl and ucl values to draw the whiskers I
> need above and below the points?
>
> ______________________________________________
> 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.
>


-- 
http://had.co.nz/



More information about the R-help mailing list