[R] Creating dummy variable using ifelse statement while you also retain NA's

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Wed Aug 17 20:50:26 CEST 2016

I cannot imagine why you would want ifelse to support an na.rm argument, and your phrase 'still retains the missing data denoted as "NA"' seems exactly how ifelse  works anyway. You may need to study how NA values work... basic things like TRUE & NA ==NA and when you should use is.na(). The"Introduction to R" document may be helpful, as might "The R Inferno".

The usual boilerplate at this point applies... before posting again, read the Posting Guide, post your question using plain text format, and provide a reproducible example that illustrates your concern on a concrete manner.
Sent from my phone. Please excuse my brevity.

On August 17, 2016 11:24:45 AM PDT, Olu Ola via R-help <r-help at r-project.org> wrote:
>Hello,I am trying to create a dummy variable using the ifelse
>statement. However, the ifelse statement does not recognize na.rm =
>How can I create a dummy variable so that it still retains the missing
>data denoted as "NA" ?
>	[[alternative HTML version deleted]]
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list