[R] Overlay plots from different data sets using the Lattice package

hadley wickham h.wickham at gmail.com
Tue Jan 15 19:37:37 CET 2008


On Jan 15, 2008 12:27 PM, Dieter Menne <dieter.menne at menne-biomed.de> wrote:
> hadley wickham <h.wickham <at> gmail.com> writes:
>
> > qplot(vals, ..density.., data = data.frame.A, geom="histogram", facets
> > = factor.1 ~ factor.2, binwidth = 1) + geom_density(data=data.frame.B)
>
> uhh.. how should I understand "y (?)=..density.."

Yes, that does require a little explanation.  The .. tells ggplot the
variable (density) is not in the original dataset, but is instead
produce by the statistical transformation (stat_bin for the histogram
and stat_density for the density plot).  By default the histogram uses
..count.. (the raw count) while density uses ..density.., so y =
..density.. tells them both to use the same scale (you could also use
y = ..count.. but count on a density is plot is a little less common)

Hadley


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




More information about the R-help mailing list