Learn R Programming

clock (version 0.7.1)

date_group: 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)

Value

x, grouped at precision.

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.

Examples

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

Run the code above in your browser using DataLab