[R] Find x value of density plots

Duncan Murdoch murdoch.duncan at gmail.com
Tue Dec 6 19:48:39 CET 2011


On 06/12/2011 1:42 PM, Pavan G wrote:
> Hello All,
>
> How do I find the x value at max density for say, this plot
> plot(density(rnorm(1000)))

d <- density(rnorm(1000))
plot(d)

abline(v=d$x[which.max(d$y)])

Duncan Murdoch



More information about the R-help mailing list