I have a large dataframe with in the format as seen in the bottom of my comment, but without the last 2 columns.
It is sorted by Name (chr), and Date(POSIXct). I want to add a 4. and 5. column, where the first and last occurence of each Name is listed, like this:
ID | Name | Date | First | Last |
---|---|---|---|---|
3 | A | 2010-10-01 | 2010-10-01 | 2010-12-31 |
4 | A | 2010-12-03 | 2010-10-01 | 2010-12-31 |
1 | A | 2010-12-31 | 2010-10-01 | 2010-12-31 |
2 | B | 2012-01-01 | 2012-01-01 | 2012-01-01 |
How can I do that? There are NAs and NULLs in both Name and Date column.