Your message doesn't help us very much. You haven't said what kind of
calculation it is you want to do, and that certainly matters. For
example, for some kinds of computations the solution you started below
would work fine:
M - matrix(1:16, 4, 4)
is.na(diag(M)) - TRUE
M
[,1] [,2] [,3]
See upper.tri and lower.tri.
I think that you might also look for specific packages that function using
matrices, from what I have seen these often have the capacity to ignore the
diagonal or use just the upper or lower triangle. This is not an area that I
use very much, but I have seen
I am sorry about that.
I like to do column mean, sd, var
as well as kmeans on the matrix
does this na.rm = TRUE work for such fuctions and only the diagonal is
ignored?
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED],r-help@stat.math.ethz.ch
Subject: RE: [R] NA's?
Date: Thu, 31 Mar 2005 11:42:05
in
R
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED],r-help@stat.math.ethz.ch
Subject: RE: [R] NA's?
Date: Thu, 31 Mar 2005 11:42:05 +1000
Your message doesn't help us very much. You haven't said what kind of
calculation it is you want to do, and that certainly matters. For
example, for some kinds
.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Asha Jayanthi
Sent: Thursday, 31 March 2005 3:48 PM
To: r-help@stat.math.ethz.ch
Subject: RE: [R] NA's?
I am sorry about that.
I like to do column mean, sd, var
as well as kmeans on the matrix
does this na.rm
Some careful use of is.na() may help.
Either by using it to remove NA values or as part of the if statement.
Or:
my.wdir - na.omit(dat$wdir)
for(i in 1:length(my.wdir)) {
#etc
-Original Message-
From: [EMAIL PROTECTED] on behalf of [EMAIL PROTECTED]
Sent:
The following provides a sample use if is.na in an context
similar to yours, that also uses vector arithmetic, so you don't need a
loop:
tst - (-2):2
(tst2 - 1+tst/(tst^2))
[1] 0.5 0.0 NaN 2.0 1.5
(sel - (tst2==0))
[1] FALSE TRUENA FALSE FALSE
sel[is.na(tst2)] - FALSE
tst2[sel]
?data.frame will show na.action is not an argument to data.frame.
na.omit(data.frame(east(G), north(G), sites1)) might be what you want.
On Mon, 13 Oct 2003, Martin Wegmann wrote:
I run R inside GRASS and tried to obtain values of a raster file inside GRASS
but this raster image contains