clock-setters {clock}R Documentation

Calendar setters

Description

This family of functions sets fields in a calendar vector. Each calendar has its own set of supported setters, which are documented on their own help page:

There are also convenience methods for setting certain components directly on R's native date and date-time types.

Some general rules about setting components on calendar types:

Usage

set_year(x, value, ...)

set_quarter(x, value, ...)

set_month(x, value, ...)

set_week(x, value, ...)

set_day(x, value, ...)

set_hour(x, value, ...)

set_minute(x, value, ...)

set_second(x, value, ...)

set_millisecond(x, value, ...)

set_microsecond(x, value, ...)

set_nanosecond(x, value, ...)

set_index(x, value, ...)

Arguments

x

⁠[object]⁠

An object to set the component for.

value

⁠[integer]⁠

The value to set the component to.

...

These dots are for future extensions and must be empty.

Details

You cannot set components directly on a time point type, such as sys-time or naive-time. Convert it to a calendar type first. Similarly, a zoned-time must be converted to either a sys-time or naive-time, and then to a calendar type, to be able to set components on it.

Value

x with the component set.

Examples

x <- year_month_day(2019, 1:3)

# Set the day
set_day(x, 12:14)

# Set to the "last" day of the month
set_day(x, "last")

[Package clock version 0.7.0 Index]