[R] Separate ablines in lattice panels

Bert Gunter gunter.berton at gene.com
Tue Jan 17 19:06:56 CET 2012


?panel.number

This tells you what panel you're in and you can use that to determine
which line to draw.

-- Bert

On Tue, Jan 17, 2012 at 9:59 AM, Doran, Harold <HDoran at air.org> wrote:
> Searched archives and found some old email threads on the topic. But mot exactly what I think I need. Suppose I have a datafile such as tmp.
>
> tmp <- data.frame(var1 = c(rnorm(1000), rnorm(1000, 1, 1)), var2 = gl(2, 1000))
>
> I'd like a plot similar to the one below, but with an abline of v=0 in the lower panel and v=1 in the upper panel. Code below creates two lines in each panel, not quite sure how to separate them by panel.
>
> densityplot(~ var1|var2, tmp,
>                              type = c('g', 'l'),
>                              layout = c(1,2),
>                                             panel = function(x, ...){
>                                             panel.densityplot(x, ...)
>                                             panel.abline(v = c(0,1))
>                                             }
> )
>
> Thank you
> Harold
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



More information about the R-help mailing list