Skip to content
Prev 363395 / 398502 Next

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

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.