Sorry, the data is:

temp <- data.frame(type1 = c("male", "female", "male", "female", "female"),
type2 = c("low", "med", "high", "low", "med"), a = c(1,2,4, NA, 3), b =
c(5,NA,5,1,2), c = c(0,0,1,1,NA))

On Tue, Mar 17, 2009 at 4:28 PM, Ferry <fmi.ml...@gmail.com> wrote:

> Hi,
>
> I have newbie question. Suppose I have the following data:
>
> temp <- data.frame(type1 = c("male", "female", "male", "female", "female"),
> type2 = c("low", "med", "high", "low", "med"), a = c(1,2,4, NA, 3), b =
>  .... [TRUNCATED]
>
> temp
>    type1 type2  a  b  c
> 1   male   low  1  5  0
> 2 female   med  2 NA  0
> 3   male  high  4  5  1
> 4 female   low NA  1  1
> 5 female   med  3  2 NA
>
> how to change all NA into 0 (zero) ? so I would have the following:
>
> temp
>     type1 type2  a  b  c
> 1   male   low  1  5  0
> 2 female   med  2  0  0
> 3   male  high  4  5  1
> 4 female   low  0  1  1
> 5 female   med  3  2  0
>
> I've been trying with which() but without success.
>
> Any pointer is appreciated.
>
> Thank you,
>
> Ferry
>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to