x1 <- rnorm(100,5,sd=2)
x2 <- rnorm(200,15,3)
x3 <- c(x1,x2)
## calculate the density function
den_x <- density(x3)]
## this can be plotted:
plot(den_x)
## the density object provides useful information, such as the bandwidth used for smoothing:
str(den_x)
Now, how can we find the local minima? by using diff
to calculate something like the second derivative of the density curve (HT answerer on SO):
which(diff(sign(diff(den_x$y)))==-2)+1