I have a random variable which I can obtain the density of
density(r)->pdf
how can I obtain the cumulative distribution function (cdf) from this pdf with R?
I tried
approxfun(pdf$x,pdf$y,yleft=0,yright=0)->f
cdf<-integrate(f,-Inf,2)
but when I plot cdf I only obtain
1.000396 with absolute error < 7.9e-05