On 5/2/06, Berton Gunter <[EMAIL PROTECTED]> 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
>

Note that the evalq can be omitted:

   { a[is.na] <- 0; a } + b

______________________________________________
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

Reply via email to