year-month-day-group: Grouping: year-month-day

Description Usage Arguments Value Examples

Description

This is a year-month-day method for the calendar_group() generic.

Grouping for a year-month-day object can be done at any precision, as long as x is at least as precise as precision.

Usage

1
2
## S3 method for class 'clock_year_month_day'
calendar_group(x, precision, ..., n = 1L)

Arguments

x

[clock_year_month_day]

A year-month-day vector.

precision

[character(1)]

One of:

  • "year"

  • "month"

  • "day"

  • "hour"

  • "minute"

  • "second"

  • "millisecond"

  • "microsecond"

  • "nanosecond"

...

These dots are for future extensions and must be empty.

n

[positive integer(1)]

A single positive integer specifying a multiple of precision to use.

Value

x grouped at the specified precision.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
steps <- duration_days(seq(0, 100, by = 5))
x <- year_month_day(2019, 1, 1)
x <- as_naive_time(x) + steps
x <- as_year_month_day(x)
x

# Group by a single month
calendar_group(x, "month")

# Or multiple months
calendar_group(x, "month", n = 2)

# Group 3 days of the month together
y <- year_month_day(2019, 1, 1:12)
calendar_group(y, "day", n = 3)

# Group by 5 nanosecond of the current second
z <- year_month_day(
  2019, 1, 2, 1, 5, 20, 1:20,
  subsecond_precision = "nanosecond"
)
calendar_group(z, "nanosecond", n = 5)

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