date-group | R Documentation |
This is a Date method for the date_group()
generic.
date_group()
groups by a single component of a Date, such as month
of the year, or day of the month.
If you need to group by more complex components, like ISO weeks, or quarters, convert to a calendar type that contains the component you are interested in grouping by.
## S3 method for class 'Date'
date_group(x, precision, ..., n = 1L, invalid = NULL)
x |
A date vector. |
precision |
One of:
|
... |
These dots are for future extensions and must be empty. |
n |
A single positive integer specifying a multiple of |
invalid |
One of the following invalid date resolution strategies:
Using either If If |
x
, grouped at precision
.
x <- as.Date("2019-01-01") + -3:5
x
# Group by 2 days of the current month.
# Note that this resets at the beginning of the month, creating day groups
# of [29, 30] [31] [01, 02] [03, 04].
date_group(x, "day", n = 2)
# Group by month
date_group(x, "month")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.