Hi,
this is probably a very trivial question but I can't figure out the right terms
to find the solution in the list archive.
I have a matrix or a data.frame or the like:
> m <- matrix(ncol=3,seq(1,9))
> m
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
and now I wonder if one can provide somehow two vectors, one containing row
numbers, the other column numbers and thereby retrieve the corresponding
elements?
E.g., providing the 2 vectors c(1,2,3) and c(1,3,1) should return the matrix
values c(1,8,3).
I ran a couple of times into this problem and always used some awkward
transformations to get around it.
But as I know R, there is probably some slick way to do this.
Thanks!!!
Werner
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.