[R] treat NA's as zero when summed up with numbers

David Winsemius dwinsemius at comcast.net
Wed Oct 12 19:33:48 CEST 2011


On Oct 12, 2011, at 12:45 PM, Samir Benzerfa wrote:

> Hello everybody,
>
>
>
> is there any way to treat NA's as zero when they are summed up with  
> numbers,
> but to treat them as NA's when summed up only with NA's.  
> Specifically want
> that: 5+NA=5, but NA+NA=NA (and not zero).
>

sum(x , na.rm=TRUE)

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list