[R] newbie graphics question: Two density plots in same frame ?
Deepayan Sarkar
deepayan.sarkar at gmail.com
Thu Nov 3 20:28:57 CET 2005
On 11/3/05, Alpert, William <William.Alpert at barrons.com> wrote:
> I swear I've scoured the help files and several texts before posting
> what feels like a dumb newbie question.
>
> How can I draw two kernel density plots in the same frame ? I have
> similar variables in two separate data frames, and I would like to show
> their two histograms/densities in a single picture. Same units, scale,
> range for both, so I'm simply trying to draw one and then add the other
> to the picture. Nothin' fancy.
Using densityplot from lattice:
library(lattice)
d1 = data.frame(x = rnorm(100))
d2 = data.frame(x = rnorm(100, mean = 0.5))
densityplot(~d1$x + d2$x, plot.points = FALSE)
-Deepayan
More information about the R-help
mailing list