[R] Adding elements in an array where I have missing data.

John Kane jrkrideau at yahoo.ca
Tue May 2 18:25:24 CEST 2006


--- Berton Gunter <gunter.berton at gene.com> wrote:

> > 
> > Here are a few alternatives:
> > 
> > replace(a, is.na(a), 0) + b
> > 
> > ifelse(is.na(a), 0, a) + b
> > 
> > mapply(sum, a, b, MoreArgs = list(na.rm = TRUE))
> > 
> 
> Well, Gabor, if you want to get fancy...
> 
> evalq({a[is.na(a)]<-0;a})+b

It's going into my tips file but what does it mean??
Thanks



> 
> (and variants...)
> 
> Cheers,
> Bert
> 
>




More information about the R-help mailing list