R ifelse avoiding change in date format [duplicate]
This question already has an answer here: How to prevent ifelse() from turning Date objects into numeric objects 6 answers I am trying to make ifesle for two dates. I have two columns- DateIn and DateOut. I need to add 3rd variable, which would show "DateOut" if there is date value, or DateIn if there is : DateIn DateOut Travel date 2010-11-24 <NA> 2010-11-24 2011-12-21 2012-01-21 2012-01-21 2010-10-25 2010-11-25 2010-11-25 2014-01-14 <NA> 2014-01-14 I tried to do that with TravelDate <- ifelse(is.na(DateIn), DateOut, DateIn) But the result I am gettin is: DateIn DateOut Travel date 2010-11-24