As you can see below, the function densityreconfigures the list containing the values xand ydensity values that can be used to create “interpolation” using the function approxfun.
d <- density(rnorm(100))
str(d)
#
#
#
#
#
#
#
#
#
pdf <- approxfun(d)
pdf(2)
#
approxfun gives a linear approximation
To check if the initial density allows d
plot(d)

pdf,
x <- seq(-2,2,by=0.01)
points(x, pdf(x))
