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 <NA> 15018
2011-12-21 2012-01-21 15151
2010-10-25 2010-11-25 14972
2014-01-14 <NA> 14972
Travel date is classified as "logical" Is there a ways how to achieve the rusult withou R transforming date to number?
Thanks a lot!