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.
resolution(x, ...)granularity(x, ...)
A timespan object.
Time vector.
E.g. a Date
, POSIXt
, numeric
or any time-based vector.
Further arguments passed to methods.
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
.