If I have two vectors of the same length A<-c(5,10) and B<-c(7,13) how can I easily turn these two vectors into a single tuple vector i. e. <
Others have mentioned lists. I see other possibilities:
cbind(A, B) # makes a column-major 2x2-"vector"
rbind(A, B) # an row major 2x2-"vector" which could also be added to an array with `abind`
It is also possible to preserve their "origins"
AB <- cbind(A=A, B=B)
array(c(AB,AB+10), c(2,2,2) )
, , 1
[,1] [,2]
[1,] 5 7
[2,] 10 13
, , 2
[,1] [,2]
[1,] 15 17
[2,] 20 23
> abind( array(c(AB,AB+10), c(2,2,2) ), AB+20)
, , 1
A B
[1,] 5 7
[2,] 10 13
, , 2
A B
[1,] 15 17
[2,] 20 23
, , 3
A B
[1,] 25 27
[2,] 30 33