Learn R Programming

santoku (version 0.10.0)

brk_width-for-datetime: Equal-width intervals for dates or datetimes

Description

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)

Arguments

width

A scalar difftime, Period or Duration object.

start

A scalar of class Date or POSIXct. Can be omitted.

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

Run this code

if (requireNamespace("lubridate")) {
  year2001 <- as.Date("2001-01-01") + 0:364
  tab_width(year2001, months(1),
        labels = lbl_discrete(" to ", fmt = "%e %b %y"))
}

Run the code above in your browser using DataLab