year-day-setters: Setters: year-day

Description Usage Arguments Value Examples

Description

These are year-day methods for the setter generics.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## S3 method for class 'clock_year_day'
set_year(x, value, ...)

## S3 method for class 'clock_year_day'
set_day(x, value, ...)

## S3 method for class 'clock_year_day'
set_hour(x, value, ...)

## S3 method for class 'clock_year_day'
set_minute(x, value, ...)

## S3 method for class 'clock_year_day'
set_second(x, value, ...)

## S3 method for class 'clock_year_day'
set_millisecond(x, value, ...)

## S3 method for class 'clock_year_day'
set_microsecond(x, value, ...)

## S3 method for class 'clock_year_day'
set_nanosecond(x, value, ...)

Arguments

x

[clock_year_day]

A year-day vector.

value

[integer / "last"]

The value to set the component to.

For set_day(), this can also be "last" to set the day to the last day of the year.

...

These dots are for future extensions and must be empty.

Value

x with the component set.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
x <- year_day(2019)

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

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

# Set to an invalid day of the year
invalid <- set_day(x, 366)
invalid

# Then resolve the invalid day by choosing the next valid day
invalid_resolve(invalid, invalid = "next")

# Cannot set a component two levels more precise than where you currently are
try(set_hour(x, 5))

clock documentation built on April 23, 2021, 1:06 a.m.