brk_width()
can be used with time interval classes from base R or the
lubridate
package.
Usage
# S3 method for Duration
brk_width(width, start)
Details
If width
is a Period, lubridate::add_with_rollback()
is used to calculate the widths. This can be useful for e.g. calendar months.
Examples
if (requireNamespace("lubridate")) {
year2001 <- as.Date("2001-01-01") + 0:364
tab_width(year2001, months(1),
labels = lbl_discrete(" to ", fmt = "%e %b %y"))
}
#> 1 Jan 01 to 31 Jan 01 1 Feb 01 to 28 Feb 01 1 Mar 01 to 31 Mar 01
#> 31 28 31
#> 1 Apr 01 to 30 Apr 01 1 May 01 to 31 May 01 1 Jun 01 to 30 Jun 01
#> 30 31 30
#> 1 Jul 01 to 31 Jul 01 1 Aug 01 to 31 Aug 01 1 Sep 01 to 30 Sep 01
#> 31 31 30
#> 1 Oct 01 to 31 Oct 01 1 Nov 01 to 30 Nov 01 1 Dec 01 to 31 Dec 01
#> 31 30 31