I have a table like this:
ID | Date | Status |
---|---|---|
101 | 2020-09-14 | 1 |
102 | 2020-09-14 | 1 |
103 | 2020-09-14 | 1 |
104 | 2020-09-14 | 2 |
105 | 2020-09-14 | 2 |
106 | 2020-09-14 | 2 |
But want a table like this:
Status | ID | Date |
---|---|---|
1 | 101,102,103 | 2020-09-14, 2020-09-14, 2020-09-14 |
1 | 104,105,106 | 2020-09-14, 2020-09-14, 2020-09-14 |
Code that i'm currently using:
note: date is in format yyyy-mm-dd before running code.
g1 <- df1 %>%
mutate(Date = as.Date(Date, format = '%Y%m%d')) %>%
group_by(status) %>%
summarise_at(c("ID", "Date"), list)
This seems to work except for the date in the new table is not in yyyy-mm-dd. For example, 2021-06-10 is converting to 18788.