date_group: Group date and date-time components

View source: R/date.R

date_groupR Documentation

Group date and date-time components

Description

date_group() groups by a single component of a date-time, such as month of the year, or day of the month.

There are separate help pages for grouping dates and date-times:

  • dates (Date)

  • date-times (POSIXct/POSIXlt)

Usage

date_group(x, precision, ..., n = 1L)

Arguments

x

⁠[Date / POSIXct / POSIXlt]⁠

A date or date-time vector.

precision

⁠[character(1)]⁠

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

...

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 precision.

Examples

# See type specific documentation for more examples
date_group(as.Date("2019-01-01") + 0:5, "day", n = 2)

clock documentation built on Sept. 11, 2024, 8:39 p.m.