You need to first get the "coordinates" of the data points that you want.
match(index(myZoo2), index(myZoo))
will match indices of 2 zoo objects, and match(as.vector(myZoo2), names(myZoo))
will get list of column numbers.
Then you subset myZoo
with coord
to get values that you want. You will still need to "massage" the data back into zoo object manually.
coord <- cbind(match(index(myZoo2), index(myZoo)), match(as.vector(myZoo2), names(myZoo)))
coord
## [,1] [,2]
## [1,] 1 3
## [2,] 2 2
## [3,] 3 1
## [4,] 1 2
## [5,] 2 1
## [6,] 3 2
## [7,] 1 3
## [8,] 2 3
## [9,] 3 1
zoo(matrix(as.matrix(myZoo)[coord], nrow = nrow(myZoo)), order.by = index(myZoo))
##
## 1/1/2000 7 4 7
## 1/2/2000 5 2 8
## 1/3/2000 3 6 3