Re: [R] Getting multiple matrix-values using a single command

2010-03-12 Thread Don MacQueen
Everyone is being too complicated. c( A[1,2] , A[3,3] ) will do what you ask. A <- matrix(seq(1,9),nrow=3) c( A[1,2] , A[3,3] ) [1] 4 9 But I would assume you have some more general problem in mind, and I do not know if this simple approach will meet those needs. -Don At 3:26 PM

Re: [R] Getting multiple matrix-values using a single command

2010-03-12 Thread David Winsemius
On Mar 12, 2010, at 2:31 PM, David Winsemius wrote: On Mar 12, 2010, at 9:26 AM, Nils Rüfenacht wrote: Dear all! I'm trying to get multiple values from a matrix by using a single command. Given a matrix A A <- matrix(seq(1,9),nrow=3,ncol=3) How can I get e.g. the values A[1,2] = 4 and

Re: [R] Getting multiple matrix-values using a single command

2010-03-12 Thread David Winsemius
On Mar 12, 2010, at 9:26 AM, Nils Rüfenacht wrote: Dear all! I'm trying to get multiple values from a matrix by using a single command. Given a matrix A A <- matrix(seq(1,9),nrow=3,ncol=3) How can I get e.g. the values A[1,2] = 4 and A[3,3] = 9 with a single command and without using a

Re: [R] Getting multiple matrix-values using a single command

2010-03-12 Thread Henrique Dallazuanna
Try this: diag(A[c(1,3),c(2,3)]) 2010/3/12 Nils Rüfenacht : > Dear all! > > I'm trying to get multiple values from a matrix by using a single command. > > Given a matrix A > > A <- matrix(seq(1,9),nrow=3,ncol=3) > > How can I get e.g. the values A[1,2] = 4 and A[3,3] = 9 with a single > command

Re: [R] Getting multiple matrix-values using a single command

2010-03-12 Thread Claudia Beleites
use a matrix of n x 2 to index. For details: sec. 5.3 "Index matrices" in the introduction. HTH Claudia Nils Rüfenacht wrote: Dear all! I'm trying to get multiple values from a matrix by using a single command. Given a matrix A A <- matrix(seq(1,9),nrow=3,ncol=3) How can I get e.g. the val