Hi reader,
Example data:
tibble::tribble(
~Item, ~`Date(dd/mm/yyyy)`, ~Amount,
"saw", "01/01/2020", 3L,
"saw", "11/03/2020", 4L,
"saw", "21/03/2020", 7L,
"saw", "01/04/2020", 9L,
"nails", "01/01/2020", 2L,
"nails", "02/01/2020", 3L,
"nails", "03/01/2020", 2L,
"nails", "04/01/2020", 4L,
"nails", "05/01/2020", 6L,
"hammer", "01/01/2020", 10L,
"hammer", "02/01/2020", 10L,
"hammer", "03/01/2020", 10L,
"ax", "01/01/2020", 10L,
"ax", "02/01/2020", 5L,
"ax", "03/01/2020", 1L
)
I am trying to find a way to filter these items into subsets one for items whos amount is increasing, one for decreasing and one for items whos amount is static.
I need a way to compare each items min(Date) to max(Date) and subset all observation into one of the respective subsets.
For this example data set saw and nails would go into increasing subset, hammer in static subset and ax in decreasing.