Current period year-to-date compared to previous period year-to-date
yoytd.Rd- This calculates the annual cumulative sum of targeted value and compares it with the previous period's annual cumulative to date sum using a standard or 5-5-4 calendar respecting any groups that are passed through with - dplyr::group_by()
- Use calculate to return the results 
Details
- This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years 
- If you provide a grouped object with - dplyr::group_by(), it will generate a complete calendar for each group
- The function creates a - tiobject, which pre-processes the data and arguments for further downstream functions
standard calendar
- The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week 
- It automatically accounts for leap years every four years to match the Gregorian calendar 
5-5-4 calendar
- The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period. 
- This system is commonly used in retail and financial reporting 
Examples
yoytd(sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)
#> 
#> ── Year-to-date over previous year-to-date ─────────────────────────────────────
#> Function: `yoytd` was executed
#> 
#> ── Description: ──
#> 
#> This creates a daily `cumsum()` of the previous year quantity and compares it
#> with the daily `cumsum()` current year quantity from the start of the standard
#> calendar year to the end of the year
#> 
#> ── Calendar: ──
#> 
#> • The calendar aggregated order_date to the day time unit
#> • A standard calendar is created with 0 groups
#> • Calendar ranges from 2021-05-18 to 2024-04-20
#> • 222 days were missing and replaced with 0
#> • New date column date and year was created from order_date
#> 
#> ── Actions: ──
#> 
#> Error in str_detect(x@action@value[[1]], "32m"): could not find function "str_detect"