[R] [Solved] Can I replace NA by 0 (if yes, how) ?

Ptit_Bleu ptit_bleu at yahoo.fr
Thu Nov 8 11:05:08 CET 2007


I was sure that there was such a solution.
I would have liked to find it.

Thank you for your help.
Ptit Bleu.
-----------------------------


Wollkind, Steven wrote:
> 
> You don't need to loop.  You can just do
> 
> pfit$coefficients[is.na(pfit$coefficients)] <- 0 
> 
> 
> 
> Steve Wollkind
> Associate Analyst
> Geode Capital Management, LLC
> 1 Post Office Square / 28th Floor / Boston, MA 02109
> steven.wollkind at geodecapital.com
> Tel:   (617) 392-8991
> Fax:  (617) 476-6389
> 
> This e-mail, and any attachments hereto, are intended for use by the
> addressee(s) only and may contain information that is (i) confidential
> information of Geode Capital Management, LLC and/or its affiliates,
> and/or (ii) proprietary information of Geode Capital Management, LLC
> and/or its affiliates. If you are not the intended recipient of this
> e-mail, or if you have otherwise received this e-mail in error, please
> immediately notify me by telephone (you may call collect), or by e-mail,
> and please permanently delete the original, any print outs and any
> copies of the foregoing. Any dissemination, distribution or copying of
> this e-mail is strictly prohibited. 
> 
> 
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of Ptit_Bleu
> Sent: Wednesday, November 07, 2007 11:28 AM
> To: r-help at r-project.org
> Subject: Re: [R] Can I replace NA by 0 (if yes, how) ?
> 
> 
> I found this solution but it must another one much more "R-friendly" ?
> 
> for (a in 1:9) {
> if (is.na(pfit$coefficients[[a]])) (pfit$coefficients[[a]]<-0)
> }
> 
> Again thank you in advance for explainations concerning NA,
> Ptit Bleu.
> -- 
> View this message in context:
> http://www.nabble.com/Can-I-replace-NA-by-0-%28if-yes%2C-how%29---tf4765
> 597.html#a13630590
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/Can-I-replace-NA-by-0-%28if-yes%2C-how%29---tf4765597.html#a13644272
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list