I have a data frame that contains count of sales by seller, year and month, called sales_by_month
:
library(tidyverse)
sales_by_month <- tribble(
~Seller, ~Year, ~Month, ~Sales,
"John Doe", 2018, 1, 82,
"John Doe", 2018, 2, 72,
"John Doe", 2018, 3, 42,
"Sally Jane", 2018, 1, 25,
"Sally Jane", 2018, 2, 77)
I need to subset this dataset by only those sellers where their sales are increasing over time, and I cannot figure out how to do it.
The resulting subset dataset should contain;
Seller Year Month Sales
Sally Jane 2018 1 25
Sally Jane 2018 2 77
Because Sally's sales are increasing, while John's sales are decreasing.
Any help would be very much appreciated!!