Learn R Programming

clock (version 0.7.1)

calendar-boundary: Boundaries: calendars

Description

  • calendar_start() computes the start of a calendar at a particular precision, such as the "start of the quarter".

  • calendar_end() computes the end of a calendar at a particular precision, such as the "end of the month".

For both calendar_start() and calendar_end(), the precision of x is always retained.

Each calendar has its own help page describing the precisions that you can compute a boundary at:

  • year-month-day

  • year-month-weekday

  • year-week-day

  • iso-year-week-day

  • year-quarter-day

  • year-day

Usage

calendar_start(x, precision)

calendar_end(x, precision)

Value

x at the same precision, but with some components altered to be at the boundary value.

Arguments

x

[calendar]

A calendar vector.

precision

[character(1)]

A precision. Allowed precisions are dependent on the calendar used.

Examples

Run this code
# Hour precision
x <- year_month_day(2019, 2:4, 5, 6)
x

# Compute the start of the month
calendar_start(x, "month")

# Or the end of the month, notice that the hour value is adjusted as well
calendar_end(x, "month")

Run the code above in your browser using DataLab