Hi folks,

 

I'm trying to do something that seems like it should easy, but it apparently 
isn't.  I have two large matrices, both containing a number of missing values 
at different cells. I would like to average these matrices, but the NAs are 
preventing me. I get a "non-numeric argument to binary operator" error.  That's 
the first problem.

 

test<-read.csv("test.csv",header=FALSE)
test2<-read.csv("test2.csv",header=FALSE)
test_ <- as.matrix(test,na.rm=T) 
test2_ <- as.matrix(test2,na.rm=T) 
testave<- (test_+test2_)/2

??

 

So off the bat I'm doing something wrong.

 

How would I replace the missing values in one matrix with the corresponding 
non-missing values in another?  It's acceptable to me if I only have one value 
representing the average for a particular coordinate.

 

Any help would be appreciated!  

 

 

 

_________________________________________________________________
Bing™ finds low fares by predicting when to book. Try it now.

=WLHMTAG&crea=TXT_MTRHPG_Travel_Travel_TravelDeals_1x1
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to