I've got a two different vectors - one with zeros and random real numbers between 0-0.5 (vec1) and another ordered vector (vec2):
vec1 <- c(0.42887017, 0.26703377, 0, 0, 0, 0.33203175, 0.16787991, 0, 0, 0.19483491, 0.41869476, 0.05820833, 0.37449489, 0, 0, 0, 0, 0, 0.44390140, 0.19483491, 0.06736238, 0.31630117, 0, 0, 0, 0, 0, 0, 0.27121130, 0)
vec2 <- c(-0.1, -0.1, -0.1, -0.1, -0.1, 1.2, 1.2, 1.2, 1.2, 1.2, 0.5, 0.5, 0.5, 0.5, 0.5, 2.0, 2.0, 2.0, 2.0, 2.0, -0.6, -0.6, -0.6, -0.6, -0.6, 0.25, 0.25, 0.25, 0.25, 0.25)
For the first vector, vec1, I want create clusters of vectors > 0 and in the second vector, vec2, I want the equivalently positioned indexed elements to be clustered as follows (see bold):
vec1 -> 0.42887017, 0.26703377, 0, 0, 0, 0.33203175, 0.16787991, 0, 0, 0.19483491, 0.41869476, 0.05820833, 0.37449489, 0, 0, 0, 0, 0, 0.44390140, 0.19483491, 0.06736238, 0.31630117, 0, 0, 0, 0, 0, 0, 0.27121130, 0
vec2 -> -0.1, -0.1, -0.1, -0.1, -0.1, 1.2, 1.2, 1.2, 1.2, 1.2, 0.5, 0.5, 0.5, 0.5, 0.5, 2.0, 2.0, 2.0, 2.0, 2.0, -0.6, -0.6, -0.6, -0.6, -0.6, 0.25, 0.25, 0.25, 0.25, 0.25
Preferably the output should be in a lists of matrices with the equivalent indices:
[[1]]
[,1] [,2]
[1,] 0.4288702 -0.1
[2,] 0.2670338 -0.1
[[2]]
[,1] [,2]
[1,] 0.3320318 1.2
[2,] 0.1678799 1.2
[[3]]
[,1] [,2]
[1,] 0.19483491 1.2
[2,] 0.41869476 0.5
[3,] 0.05820833 0.5
[4,] 0.37449489 0.5
[[4]]
[,1] [,2]
[1,] 0.44390140 2.0
[2,] 0.19483491 2.0
[3,] 0.06736238 -0.6
[4,] 0.31630117 -0.6
[[5]]
[,1] [,2]
[1,] 0.2712113 0.25
Has anybody got some ideas on how to do this?
Thanks