Counting Business Days spent for shipping etc

For example, if you want to count how many business days were spent between the days your business received orders and the days you shipped for the orders, you can do the following.

  1. Install bizdays R package in Exploratory.

  2. Define a calendar (named ‘MyCalendar’ here.) for your business days in Custom R Script.
    Here is example script.

library(bizdays)
holidays <- as.character(c("2000-01-01", "2019-07-04", "2019-09-02", "2019-10-14", "2050-01-01")) #4th of July and Labor day and Columbus day

bizdays::create.calendar(name='MyCalendar', holidays=holidays, weekdays=c('sunday', 'saturday'),
                                adjust.from=adjust.next, adjust.to=adjust.previous)
                                
TRUE #This is just to pass validation of this script.

  1. Use it from mutate step.

When I have table like this…

With this mutate step…

bizdays(`Order Date`, `Ship Date`, "MyCalendar")

I can get the following Data Frame with the column for business days spent for shipping.