Here is my test dataset :
test
date app count
1 21-10-18 A 2
2 21-10-19 A 3
3 21-10-23 A 5
4 21-10-19 B 2
5 21-10-24 B 3
I would like to group the data based on app column and replace the latest date by sys.Date in the date column.
I could get the latest date per app by :
latest_date <- test %>% group_by(app)%>%slice(n())
latest_date
# A tibble: 2 x 3
# Groups: app [2]
date app count
<date> <chr> <int>
1 21-10-23 A 5
2 21-10-24 B 3
How could I find the row indexes in test dataset which are match with the rows in latest_date ? (which (test == latest_date)) ????
what I need at the end is :
date app count
1 21-10-18 A 2
2 21-10-19 A 3
3 21-12-13 A 5
4 21-10-19 B 2
5 21-12-13 B 3
Also how one could add the rows here with current date, after the max.date
of each group, which the output looks :
date app count
1 21-10-18 A 2
2 21-10-19 A 3
3 21-10-23 A 5
4 21-12-13 A 5
5 21-10-19 B 2
6 21-10-24 B 3
7 21-12-13 B 3
the add_row command from dplyr does not work on grouped data frame !