[R] lattice: overlap histogram

Deepayan Sarkar deepayan.sarkar at gmail.com
Wed Oct 29 01:41:26 CET 2008


On Tue, Oct 28, 2008 at 4:31 PM, Ferry <fmi.mlist at gmail.com> wrote:
> Dear R users,
>
> Is it possible to have an overlap histogram plot? For example:
>
> stuff <- data.frame(Mode = c("Land", "Air"), AgeGroup = c("Young", "Adult",
> "Old"), Value = sample(1:300))
> histogram( ~Value | AgeGroup * Mode, data = stuff, auto.key = TRUE)
>
> Instead of having 2 * 3 panel, I want to have just 3 panel, overlapping the
> "Mode" into the same panel.
>
> I tried the following:
> histogram( ~Value | AgeGroup, data = stuff, groups = Mode, auto.key = TRUE)
>
> but I think it gave me incorrect result.

See

http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg84387.html

but I would recommend use of densityplot() instead:

densityplot( ~Value | AgeGroup, data = stuff, groups = Mode, auto.key = TRUE)

-Deepayan



More information about the R-help mailing list