resolution: Time resolution & granularity

View source: R/resolution.R

resolutionR Documentation

Time resolution & granularity

Description

The definitions of resolution and granularity may evolve over time but currently the resolution defines the smallest timespan that differentiates two non-fractional instances in time. The granularity defines the smallest common time difference. A practical example would be when using dates to record data with a monthly frequency. In this case the granularity is 1 month, whereas the resolution of the data type Date is 1 day. Therefore the resolution depends only on the data type whereas the granularity depends on the frequency with which the data is recorded.

Usage

resolution(x, ...)

granularity(x, ...)

Arguments

x

Time vector.
E.g. a Date, POSIXt, numeric or any time-based vector.

...

Further arguments passed to methods.

Details

For dates and date-times, the argument exact = TRUE can be used to detect monthly/yearly granularity. In some cases this can be slow and memory-intensive so it is advised to set this to FALSE in these cases.

The default for dates is exact = TRUE whereas the default for date-times is exact = FALSE.

Value

A timespan object.


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