On Thu, Nov 11, 2010 at 11:45, Joon Yeong Kim <joonyeen...@gmail.com> wrote:

> I tried using panel function but wasn't sure how to get the y value for the
> peak of the densityplot.
>
> I'm thinking there should be a way to retrieve the densityplot object so
> that I can get the (x,y) values of the curve directly from the object.
>
> Anyone know how to do this?
>
>
If you are using the "density" function in the stats package it is a fairly
easy task to get the x,y coordinates at the peak:

dens <- density( rnorm(500) )
dens$x[ which.max(dens$y) ]
dens$y[ which.max(dens$y) ]


> Thank you.
>
> Joon
>
> On Thu, Nov 11, 2010 at 12:29 AM, baptiste auguie <
> baptiste.aug...@googlemail.com> wrote:
>
> > Hi,
> >
> > The easiest way might be the directlabels package from R-forge.
> > Otherwise, you could write your own panel function.
> >
> > HTH,
> >
> > baptiste
> >
> >
> > On 10 November 2010 23:01, Joon Yeong Kim <joonyeen...@gmail.com> wrote:
> > > Hi,
> > >
> > > I've been trying to find a way to label the the peak or mean of a
> > > densityplot for a while but haven't been successful. Does anyone know
> how
> > to
> > > accomplish this?
> > >
> > >
> > > Thank you for your help in advance.
> > >
> > >
> > > Joon
> > >
> > >        [[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<
> http://www.r-project.org/posting-guide.html>
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
>
>        [[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]]

______________________________________________
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.

Reply via email to