time_ceiling: Ceiling a 'tbl_time' object

Description Usage Arguments Details Examples

View source: R/time_ceiling.R

Description

This is essentially a convenient wrapper to [lubridate::ceiling_date()] that allows ceiling of a 'tbl_time' object using a period formula.

Usage

1
time_ceiling(x, period, ...)

Arguments

x

A 'tbl_time' object.

period

A formula or character specification used for time-based grouping.

If a formula, e.g. '1~year', the formula is split and parsed to form the grouping period. The 'period' argument accepts a formula of the form 'multiple ~ period' allowing for flexible period grouping. The following are examples:

* 1 Year: '1~y' * 3 Months: '3~m' * 90 Days: '90~d'

Note that while shorthand is used above, an attempt is made to recognize more explicit period names such as:

* 2 Year: '2~year' / '2~years' / '2~yearly'

The 'period' argument also accepts characters that are converted to their corresponding periods. The following are accepted:

* '"yearly"' or '"y"' * '"quarterly"' or '"q"' * '"monthly"' or '"m"' * '"weekly"' or '"w"' * '"daily"' or '"d"' * '"hour"' or '"h"' * '"minute"' or '"M"' * '"second"' or '"s"'

...

Arguments passed on to [lubridate::ceiling_date()]

Details

This function respects [dplyr::group_by()] groups.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
example_series <- create_series(~2013, 2~day)

# When you convert to a period with `side = "end"` specified,
# the highest available date in that period is chosen
example_series %>%
  as_period(1~m, side = "end")

# Sometimes you want to additionally ceiling that date so that all dates
# are consistent
# Note that lubridate::ceiling_date() rounds up to the next boundary,
# and does not stop at the end of the month.
example_series %>%
  as_period(1~m, side = "end") %>%
  time_ceiling(1~m)

DavisVaughan/tibbletime3 documentation built on May 28, 2019, 12:25 p.m.