[R] percentage from density()

Duke duke.lists at gmx.com
Fri Jan 27 23:44:43 CET 2012


Hi folks,

I know that density function will give a estimated density for a give 
dataset. Now from that I want to have a percentage estimation for a 
certain range. For examle:

 > y = density(c(-20,rep(0,98),20))
 > plot(y, xlim=c(-4,4))

Now if I want to know the percentage of data lying in (-20,2). Basically 
it should be the area of the curve from -20 to 2. Anybody knows a simple 
function to do it?

Thanks,

D.



More information about the R-help mailing list