Hi:

Perhaps this is what you were looking for:

densityplot(Age ~ Year, data = ages, group = ID, plot.points = FALSE)

HTH,
Dennis

On Thu, Jan 21, 2010 at 7:30 AM, Yi Du <abraham.du@gmail.com> wrote:

> Hi,
>
>
> I have a data set about age from 2006 to 2009 for certain individual. I
> would like to draw the kernel density estimation to age for each year. But
> I
> don't know how to draw the different plots in one graph.
>
> The data looks like:
> Year    ID      Age
> 2006    1       20
> 2006    2       30
> 2007    1       21
> 2007    2       31
> 2008    1       22
> 2009    1       23
>
> I first use hist(age) to draw the histogram for age, then use
> lines(density(age)) to draw its kernel. But since I need to draw the four
> years kernel for age in one graph, I don't need the hist. I also tried the
> package lattice of kernelplot, But I still don't know how to draw the four
> years kernel in one graph. Also, I don't need the rug(age) in kernelplot,
> how can I delete it?
>
> Thanks.
>
> --
> Yi Du
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>

	[[alternative HTML version deleted]]

