Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206503

R: Merging two date columns into one in order by id

$
0
0

I am currently working in R in data table and have two date columns (first_day and last_day) that I need to merge together into one date column (date). This needs to be done so that the column has the dates in order from smallest to largest by group (id).

Here is the data I'm working with:

ID    first_day    last_day
1     1/12/2005    1/15/2005
2     2/15/2006    2/19/2006
2     3/8/2006     3/12/2006
3     1/9/2008     1/13/2008

Here is what I'm trying to get the result to look like:

ID    first_day    last_day    Date
1     1/12/2005    1/15/2005   1/12/2005 
1     1/12/2005    1/15/2005   1/15/2005
2     2/15/2006    2/19/2006   2/15/2006
2     2/15/2006    2/19/2006   2/19/2006
2     3/8/2006     3/12/2006   3/8/2006
2     3/8/2006     3/12/2006   3/12/2006
3     1/9/2008     1/13/2008   1/9/2008
3     1/9/2008     1/13/2008   1/13/2008

Any assistance is greatly appreciated!


Viewing all articles
Browse latest Browse all 206503

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>