I currently have the following data frame:
> head(Coyote_reports_garbage)
# A tibble: 6 x 4
name_1 Date Day Collection
<chr> <date> <chr> <chr>
1 PLEASANTVIEW 2013-02-20 Wednesday Friday
2 MCCONACHIE AREA 2012-11-20 Tuesday Friday
3 MAYLIEWAN 2013-11-28 Thursday Friday
4 BROOKSIDE 2013-12-18 Wednesday Thursday
5 KIRKNESS 2012-11-14 Wednesday Friday
6 RIDEAU PARK 2013-11-15 Friday Friday
Where "name_1" represents the name of a neighbourhood, "Date" represents the date when a report was made, "Day" represent the day of the week where that report was name (in relation to the date), and "Collection" represents the garbage day in that neighbourhood. "Collection" therefore varies per neighbourhood and year.
I am trying to add a column (Day_in_relation_to_collection) where the day would be related to Collection day. If the day of the week is the same as the garbage collection day, Day_in_relation_to_collection = 0. If the day of the week is a day after collection day, Day_in_relation_to_collection = 1, etc.
name_1 Date Day Collection Day_in_relation_to_collection
<chr> <date> <chr> <chr>
1 PLEASANTVIEW 2013-02-20 Wednesday Friday 5
2 MCCONACHIE AREA 2012-11-20 Tuesday Friday 4
3 MAYLIEWAN 2013-11-28 Thursday Friday 6
4 BROOKSIDE 2013-12-18 Wednesday Thursday 6
5 KIRKNESS 2012-11-14 Wednesday Friday 5
6 RIDEAU PARK 2013-11-15 Friday Friday 0
I'm not quite sure how to do this, so any help would be appreciated.