12300
> >>> [5,]12300
> >>> [6,]12300
> >>> [7,]1 2 3 00
> >>> [8,]12300
> >>> [9,]12340
> >>> [10,]1
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,
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
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
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,
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
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
7 matches
Mail list logo