From: <Bill.Venables_at_csiro.au>

Date: Thu 31 Mar 2005 - 11:42:05 EST

> rowSums(M, na.rm = TRUE)

[1] 27 26 25 24

> colSums(M, na.rm = TRUE)

[1] 9 20 31 42

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!

http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Mar 31 11:48:18 2005

Date: Thu 31 Mar 2005 - 11:42:05 EST

*> M <- matrix(1:16, 4, 4)
*

> is.na(diag(M)) <- TRUE

*> M
*

[,1] [,2] [,3] [,4]

[1,] NA 5 9 13 [2,] 2 NA 10 14 [3,] 3 7 NA 15 [4,] 4 8 12 NA

> rowSums(M, na.rm = TRUE)

[1] 27 26 25 24

> colSums(M, na.rm = TRUE)

[1] 9 20 31 42

You can also use apply( ) with functions that will accept missing values (and ignore them) for computations on either the rows or the columns.

I have a large matrix of data .

The size of the matrix ranges from 100 x 100 to 1000 x 1000

Now i have to do computations on that. And should not consider the
diagonal

elements.

I tried setting diag(M) = NA and M = na.omit(M).

diag(M) = 0 seems like a good option but this will affect my result.

How to proceed with this. How to just ignore some specific values. what
if i

want to consider only the upper / lower triangular matrix

Asha

http://adfarm.mediaplex.com/ad/ck/4686-26272-10936-31?ck=RegSell Start
your

business.

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!

http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Mar 31 11:48:18 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:30:57 EST
*