You'll of course first need to define what you consider low vs. high density.
Assuming you can decide on a cutoff distance between consecutive elements, tol
, below which two consecutive elements are considered to be densely packed, you could use something like this:
f <- function(x, tol) {
x[tol < diff(c(-Inf, x))]
}
original_vector <- c(0.001,0.002,0.003,0.004,0.1001,0.1002,0.1003,0.1004,0.1005,
0.5003,0.5004)
f(original_vector, tol = 0.002)
# [1] 0.0010 0.1001 0.5003