The goal of mendr is to simplify the task of creating a calendar of dates for a recurring process.
A typical use case for this is to import the data produced by
mendr into Microsoft Planner via a Power Automate Flow. We
describe this process below.
First, let’s create a dataset. Here we need a list of tasks, and for each task an offset relative to the first working day of the month. We count using index zero, so the first working day of the month is 0, the second working day of the month is 1 and so on. We can also work backwards: -1 is the first working day prior to the first working day of the month.
After creating the dataset, we call create_calendar() in
order to store a calendar of non-working days that will be used to
calculate the appropriate dates for our schedule. By default, this
stores known non-working days for Auckland Council staff from Labour Day
2022 to Labour Day 2024.
tasks <- data.frame(
tasks = c("Send email reminder", "Extract data", "Run report"),
offsets = c(-2, 0, 1)
)
create_calendar()Although we manually created the data here, we would typically store this in an Excel spreadsheet and read it using the readxl package.
Next, let’s convert our offsets into actual dates for the first three months of 2023.
schedule <- create_schedule(
schedule_data = tasks,
starting_month = "2023-01",
iterations = 3
)
schedule
#> tasks offsets date
#> 1 Send email reminder -2 2022-12-22
#> 2 Extract data 0 2023-01-09
#> 3 Run report 1 2023-01-10
#> 4 Send email reminder -2 2023-01-27
#> 5 Extract data 0 2023-02-01
#> 6 Run report 1 2023-02-02
#> 7 Send email reminder -2 2023-02-27
#> 8 Extract data 0 2023-03-01
#> 9 Run report 1 2023-03-02We can pass the optional filepath argument to
create_schedule too, and this saves the output to an Excel
file. Assuming we’ve done so, we can now reference that file in our
Power Automate flow.
To progress, we first create a new Plan in Microsoft Planner.