I currently have a list of transactions and I would like to add a categorical value to each of them depending on the age of the transaction. Sample Data:
Date Transaction
9/2/2020 44
8/29/2020 65.3
8/29/2020 34
8/29/2020 195
8/28/2020 180
8/28/2020 195
8/28/2020 48
8/27/2020 195
8/27/2020 65.3
8/27/2020 77
Pseudocode:
today<- lubridate::day(Sys.Date())
mutate(Age= case_when(
Date between(today, today -7) ~ "< Week Old",
Date between(today, today -30) ~ "30days Old",
Date between(today, today -60) ~ "60days Old",
Date >= between(today, today -90) ~ "90days+ Old"))
Is it possible to filter data in a mutate using between for date ranges?
#Currently familiarizing and exploring the cut suggestion, thanks