Public-Health-Scotland / phsmethods

An R package to standardise methods used in Public Health Scotland (https://public-health-scotland.github.io/phsmethods/)
https://public-health-scotland.github.io/phsmethods/
54 stars 13 forks source link

Fix fin_year to work with dplyr 1.0.0 #36

Closed alice-hannah closed 4 years ago

alice-hannah commented 4 years ago

As of dplyr v1.0.0, right_join() no longer sorts the rows of the output by the order of the RHS argument (see release notes).

As a result, fin_year() no longer works as expected - see following reprex;

library(phsmethods)
library(dplyr)
library(lubridate)

data <- tibble(
  dates = c(dmy(01012021), dmy(05011994), NA, dmy(01012021))
)

data %>%
  mutate(fy = fin_year(dates))

#  A tibble: 4 x 2
#  dates      fy     
#  <date>     <chr>  
# 1 2021-01-01 2020/21
# 2 1994-01-05 2020/21
# 3 NA         1993/94
# 4 2021-01-01 NA/NA  

I'll fix and open a pull request for this 👍 Thanks, Alice