Suppose I have a table like:
> A = data.table(c(1,2,3),c(4,5,6),c(7,8,9))
> A
V1 V2 V3
1: 1 4 7
2: 2 5 8
3: 3 6 9
I want to select the first column of the first row, second of the second row and third of the third row, getting the result:
> B
[1] 1 5 9
I've tried something like:
B = A[,c(1,2,3)]
But that does not work. Is it possible to do this? (Obviously in my actual use case the column indexes for each row are going to be variables, but I can guarantee a vector of length equal to the number of rows in the table)