Created a matrix named GroMatrix.
GroMatrix=matrix(c(1,2,3,4,5,2,3,4,5,6,3,4,5,6,7,4,5,6,7,8),byrow=TRUE,nrow=4)
I want to use this matrix as reference for entering data in a new column of my existing data frame by looking up data from two different columns of the same row to be treated as row number and column number of matrix. I was trying with following method but in vain.
Df$NewCol=GroMatrix[Df$Col1,Df$Col2]
Col1 and Col2 are two variables of Dataframe Df and both these columns are numeric (integers). On running the above command, I am getting a number of new observations added to my dataframe namely NewCol[,1], NewCol[,2], and so on. Need help .