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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ptit_Bleu Sent: Wednesday, November 07, 2007 11:28 AM To: r-help@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@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@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.