I have a vector of x. I would like to create a matrix of pair elements which their difference is less than or equal 1e-2. How can I do this in R?
x = c(0.0001560653, 0.0001685597, 0.0002793819, 0.0006336307, 0.0455676525,
0.3184740837, 0.3195122279, 0.3195122606)
i = which(diff(x) <= 1e-2)
My desired matrix is as follows:
> M
[,1] [,2]
[1,] 0.0001560653 0.0001685597
[2,] 0.0001685597 0.0002793819
[3,] 0.0002793819 0.0006336307
[4,] 0.3184740837 0.3195122279
[5,] 0.3195122279 0.3195122606
Like that: