[R] replace NA value with 0

Gabor Csardi csardi at rmki.kfki.hu
Fri Sep 14 10:56:05 CEST 2007


On Fri, Sep 14, 2007 at 09:46:57AM +0100, S Ellison wrote:
> 
> 
> >>> Gabor Csardi <csardi at rmki.kfki.hu> 14/09/2007 09:27:03 >>>
> >x[ is.na(x) ] <- 0
> >
> >should work in most cases i think.
> 
> ... only you probably shouldn't be doing that at all. Words like 'bias' spring to mind...
> 
> Woudn't it be better to accept the NA's and find methods that handle them as genuinely missing. R is usually quite good at that.

Although in some cases the proper handling of NA values is to treat 
them az zeros.... 

I like this list because if you ask a question, 
they don't only solve it immediately (in five different ways), but they
persuade you that what you're trying to do is actually 
incorrect/stupid/uninteresting or your problem just makes no sense at all.
:)

Gabor

> On Fri, Sep 14, 2007 at 10:08:19AM +0200, Alfredo Alessandrini wrote:
> > Hi,
> > 
> > how can I replace NA value with 0:
> 
> 
> *******************************************************************
> This email and any attachments are confidential. Any use, co...{{dropped}}
> 
> ______________________________________________
> R-help at 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.

-- 
Csardi Gabor <csardi at rmki.kfki.hu>    MTA RMKI, ELTE TTK



More information about the R-help mailing list