Re: [R] Taking all complete diagonals of a matrix

2011-07-20 Thread Nordlund, Dan (DSHS/RDA)
-Original Message- From: Peter Lomas [mailto:peter.lo...@ucalgary.ca] Sent: Tuesday, July 19, 2011 6:42 PM To: Nordlund, Dan (DSHS/RDA) Cc: r-help@r-project.org Subject: Re: [R] Taking all complete diagonals of a matrix Thanks very much to everyone who replied. Peter got me on my

Re: [R] Taking all complete diagonals of a matrix

2011-07-20 Thread peter dalgaard
complete diagonals of a matrix Hi R-Help! I am trying to find a nicer way of extracting all the complete diagonals of a matrix. I am working with very large matrices that have many more rows than columns. I want to be able to extract each of the diagonals that are as long as the number

[R] Taking all complete diagonals of a matrix

2011-07-19 Thread Peter Lomas
Hi R-Help! I am trying to find a nicer way of extracting all the complete diagonals of a matrix. I am working with very large matrices that have many more rows than columns. I want to be able to extract each of the diagonals that are as long as the number of columns in the matrix. I have

Re: [R] Taking all complete diagonals of a matrix

2011-07-19 Thread Nordlund, Dan (DSHS/RDA)
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Peter Lomas Sent: Tuesday, July 19, 2011 2:16 PM To: r-help@r-project.org Subject: [R] Taking all complete diagonals of a matrix Hi R-Help! I am trying to find a nicer way

Re: [R] Taking all complete diagonals of a matrix

2011-07-19 Thread Dennis Murphy
Hi: Does this work for you? mydiags - function(mat) diag(mat[seq_len(ncol(mat)), ]) # Example: set.seed(103) u - matrix(rpois(200, 10), ncol = 10) # dim(u) # [1] 20 10 mydiags(u) # [1] 7 12 6 13 12 6 5 6 14 6 u[1:10, ] # as a double check HTH, Dennis On Tue, Jul 19, 2011 at 2:15

Re: [R] Taking all complete diagonals of a matrix

2011-07-19 Thread Peter Lomas
, Dan (DSHS/RDA) nord...@dshs.wa.gov wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Peter Lomas Sent: Tuesday, July 19, 2011 2:16 PM To: r-help@r-project.org Subject: [R] Taking all complete diagonals of a matrix Hi R