mixtime: Temporal data for better analytics
Time is inherently complex, spanning time zones, calendar systems, and many different temporal resolutions, from event data recorded with millisecond precision to annual reports that aggregate an entire year into a single point. Existing data structures for time typically support only a single granularity, forcing analysts to misrepresent temporal semantics in order to use standard analysis and visualisation tools. For example, it is common to encode monthly data as dates using the first day of the month, or to aggregate everything up to the coarsest common granularity, both of which silently discard information and increase the risk of downstream errors. Analysis across multiple granularities adds to this complexity (e.g. ABS increasing CPI reporting frequency from quarterly to monthly), which existing data types simply aren't designed to handle.
The mixtime R package overcomes these limitations with granules: first-class extensible objects that characterise temporal semantics, connected via calendar algebra into a traversable graph that supports arithmetic and comparisons across granularities. Time points can further take different modes (linear or cyclical, durations or intervals) and be discrete time spans or continuous time instants. Each combination of properties determines which operations are valid. This talk shows how mixtime's semantic-preserving design enables better tools for exploratory time series analysis. I'll showcase new additions to the ggtime package built directly on this foundation: scale_x_mixtime() for correctly positioning mixed-granularity observations, geom_time_line() for connecting them, and coord_calendar() for arranging timelines in calendar layouts. I will close with a broader look at other analysis tasks that mixtime facilitates with safer semantic-preserving operations.