Learn R Programming

clock (version 0.7.1)

year-week-day-boundary: Boundaries: year-week-day

Description

This is an year-week-day method for the calendar_start() and calendar_end() generics. They adjust components of a calendar to the start or end of a specified precision.

Usage

# S3 method for clock_year_week_day
calendar_start(x, precision)

# S3 method for clock_year_week_day calendar_end(x, precision)

Value

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

Arguments

x

[clock_year_week_day]

A year-week-day vector.

precision

[character(1)]

One of:

  • "year"

  • "week"

  • "day"

  • "hour"

  • "minute"

  • "second"

  • "millisecond"

  • "microsecond"

  • "nanosecond"

Examples

Run this code
x <- year_week_day(2019:2020, 5, 6, 10)
x

# Compute the last moment of the last week of the year
calendar_end(x, "year")

# Compare that to just setting the week to `"last"`,
# which doesn't affect the other components
set_week(x, "last")

Run the code above in your browser using DataLab