Re: [R] replace NA value with 0

From: Gabor Csardi <csardi_at_rmki.kfki.hu>
Date: Fri, 14 Sep 2007 10:27:03 +0200

x[ is.na(x) ] <- 0

should work in most cases i think.

Gabor

On Fri, Sep 14, 2007 at 10:08:19AM +0200, Alfredo Alessandrini wrote:
> Hi,
>
> how can I replace NA value with 0:
>
> 1991 217 119 103 109 137 202 283 240 146 NA
> 1992 270 174 149 144 166 239 278 237 275 NA
> 1993 146 111 104 89 98 131 153 148 175 NA
> 1994 177 123 146 124 121 200 266 191 240 106
> 1995 145 98 95 89 95 130 183 161 164 129
> 1996 145 98 89 90 93 138 158 131 161 161
>
> 1991 217 119 103 109 137 202 283 240 146 0
> 1992 270 174 149 144 166 239 278 237 275 0
> 1993 146 111 104 89 98 131 153 148 175 0
> 1994 177 123 146 124 121 200 266 191 240 106
> 1995 145 98 95 89 95 130 183 161 164 129
> 1996 145 98 89 90 93 138 158 131 161 161
>
>
> Best wishes,
>
> Alfredo
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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

______________________________________________
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.
Received on Fri 14 Sep 2007 - 08:30:23 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 14 Sep 2007 - 08:35:53 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.