[R] Handling missing data

jim holtman jholtman at gmail.com
Fri Oct 9 17:59:11 CEST 2009


What you want is:

book$r<-ifelse(is.na(book$r), 10,book$x+20)

On Fri, Oct 9, 2009 at 5:46 AM, premmad <mtechprem at gmail.com> wrote:
>
> I have one column
> x
> 97
> 94
> 91
> 90
> NA
> NA
> NA
> NA
> I tried
> book$r<-ifelse(book$x!=NA,book$x+20,10)
> I expect to get the result as follows
> 107
> 104
> 91
> 90
> 10
> 10
> 10
> 10
> But what i was getting is empty column of variable r.How to solve this
>
> --
> View this message in context: http://www.nabble.com/Handling-missing-data-tp25539335p25818365.html
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list