timespan: Timespans

View source: R/timespan.R

timespanR Documentation

Timespans

Description

Timespans

Usage

timespan(units, num = 1L, ...)

new_timespan(units, num = 1L)

is_timespan(x)

timespan_unit(x)

timespan_num(x)

Arguments

units

A unit of time, e.g. "days", "3 weeks", lubridate::weeks(3), or just a numeric vector.

num

Number of units. E.g. units = "days" and num = 3 produces a timespan width of 3 days.

...

Further arguments passed onto methods.

x

A timespan.

Details

timespan() can be used to create objects of class 'timespan' which are used widely in timeplyr.

new_timespan() is a bare-bones version that does no checking or string parsing and is intended for fast timespan creation.

timespan_unit() is a helper that extracts the unit of time of the timespan.

timespan_num() is a helper that extracts the number of units of time.

Value

A timespan object.

Examples

library(timeplyr)

timespan("week")
timespan("day")
timespan("decade")

# Multiple units of time

timespan("10 weeks")
timespan("1.5 hours")

# These are all equivalent
timespan(NULL, 3);timespan(3);timespan(NA_character_, 3)


timeplyr documentation built on April 3, 2025, 6:15 p.m.