Re: [R] Extract entries from matrix

2015-11-04 Thread Jorge I Velez
12300 > >>> [5,]12300 > >>> [6,]12300 > >>> [7,]1 2 3 00 > >>> [8,]12300 > >>> [9,]12340 > >>> [10,]1

Re: [R] Extract entries from matrix

2015-10-28 Thread Boris Steipe
2345 >>> [12,]12345 >>>> t(sapply(1:8, function(x) diag(m[x:12, ]))) >>> [,1] [,2] [,3] [,4] [,5] >>> [1,]00000 >>> [2,] 0 0 30 0 >>> [3,]02300 >>> [4,

Re: [R] Extract entries from matrix

2015-10-28 Thread Jorge I Velez
12345 >> [8,]12345 >> >> These are all of the diagonals from the 1st through 8th rows. The first 3 >> begin with 0 so we leave them out, but then we have 4th: 1, 2, 3; 5th: 1, >> 2, 3; 6th: 1, 2, 3, 4, etc so you must have some addition

Re: [R] Extract entries from matrix

2015-10-27 Thread Jorge I Velez
ege Station, TX 77840-4352 > > > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jorge I > Velez > Sent: Tuesday, October 27, 2015 2:44 PM > To: jim holtman > Cc: R-help > Subject: Re: [R] Extract entries from matrix

Re: [R] Extract entries from matrix

2015-10-27 Thread David L Carlson
ge- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jorge I Velez Sent: Tuesday, October 27, 2015 2:44 PM To: jim holtman Cc: R-help Subject: Re: [R] Extract entries from matrix Dear Jim, Thank you very much for your quick reply. I am sorry for the confusion it may have caused,

Re: [R] Extract entries from matrix

2015-10-27 Thread Jorge I Velez
Dear Jim, Thank you very much for your quick reply. I am sorry for the confusion it may have caused, but I messed up the indexes in my example. I would like, from the following matrix "m" ## input m <- structure(c(0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 2L, 2L, 2L, 2L, 2L, 2

Re: [R] Extract entries from matrix

2015-10-27 Thread jim holtman
If you want to use the numbers you gave a the index into the matrix, then you can create a matrix with the values and then index into 'm'. I don't see a '4' in the output example you gave using your index values: > m <- structure(c(0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, + 1L, 1L, 1L

[R] Extract entries from matrix

2015-10-27 Thread Jorge I Velez
Dear R-help, I am working with a matrix "m" from which I would like to extract some elements. An toy example is as follows: ## input matrix m <- structure(c(0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,