kdplot <-
function(x,rval=15,xlab="X",ylab="Y"){
#
# Compute the kernel density estimator for a range of values
# and plot results.
#
# x contains vector of observations
#
x<-x[!is.na(x)] # Remove any missing values
y<-sort(x)
z<-1
temp<-floor(.01*length(x))
if(temp==0)temp<-5
ibot<-y[temp]
itop<-y[floor(.99*length(x))]
xaxis<-seq(ibot,itop,length=rval)
for(i in 1:rval)z[i]<-kerden(x,0,xaxis[i])
plot(xaxis,z,xlab=xlab,ylab=ylab)
lines(xaxis,z)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.