R: Group date and date-time components

date_group {clock} | R 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)

[Package clock version 0.4.1 Index]