In R, I would like to subset a matrix by using an array that contains locations. For example, if I had this matrix
mymatrix <- matrix(c(1,2,3,4,5,6,7,8,9),ncol=3,byrow=TRUE)
I would like to be able to return an array that has the values found in columns
mycols <- c(2,3,2)
But mymatrix[,mycols]
returns a 3x3 matrix and not the result I would like, namely
c(2,6,8)
Google and "subset" don't seem to be helping me. Can anyone point me in the right direction? Thx, mconsidine