[R] lattice histogram
Mendiburu, Felipe (CIP)
F.MENDIBURU at CGIAR.ORG
Sun Mar 4 15:14:43 CET 2007
Steve,
it says resp <- rnorm(200) must be resp <- rnorm(100)
regards
Felipe
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of steve
Sent: Sunday, March 04, 2007 8:58 AM
To: r-help at stat.math.ethz.ch
Subject: Re: [R] lattice histogram
Hi,
When I tried this the groups had sizes 36 30 34 as expected, but
the annotations "n = " were 68 72 60 - twice as large. I don't
understand why.
Steve
Renaud Lancelot wrote:
> Here is an example using the grid package to annotate the graphs:
>
> library(lattice)
> library(grid)
> resp <- rnorm(200)
> group <- sample(c("G1", "G2", "G3"), replace = TRUE, size = 100)
> histogram(~ resp | group,
> panel = function(x, ...){
> std <- round(sd(x), 2)
> n <- length(x)
> m <- round(mean(x), 2)
> panel.histogram(x, ...)
> x1 <- unit(1, "npc") - unit(2, "mm")
> y1 <- unit(1, "npc") - unit(2, "mm")
> grid.text(label = bquote(n == .(n)), x = x1, y = y1, just = "right")
> grid.text(label = bquote(hat(m) == .(m)), x = x1, y = y1 - unit(1,
> "lines"), just = "right")
> grid.text(label = bquote(hat(s) == .(std)), x = x1, y = y1 -
> unit(2, "lines"), just = "right")
> })
______________________________________________
R-help at 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
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list