I have a data frame with columns that contain duplicate information and gaps. For example, lets say the data frame has both START_DATE and BEGIN_DATE. They both represent the same thing. The data looks like this:
START_DATE BEGIN_DATE
---------- ----------
NA 10/10/2011
NA 12/12/2011
9/4/2011 9/4/2011
3/22/2014 3/22/2014
5/5/2011 NA
I want:
DATE
-------
10/10/2011
12/12/2011
9/4/2011
3/22/2014
5/5/2011
This doesn't work for a couple of reasons:
transform(df, DATE = if(is.na(START_DATE)) BEGIN_DATE else START_DATE)
What is the right way to do this in R?