-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
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
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
-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
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
, 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
6 matches
Mail list logo