Skip to contents

phinterval (development version)

Features

  • New phint_unoverlap() resolves overlaps across elements of a <phinterval> vector by trimming each element against all preceding elements.

    • An optional priority argument groups elements by priority, so that lower-priority elements are trimmed against higher-priority elements instead of by row-order.

    • priority_order controls whether lower ("asc") or higher ("desc") priority values are processed first, or whether groups are processed in order of first appearance ("appearance").

    • within_priority controls whether overlaps within the same priority group are resolved sequentially ("sequential") or left as-is ("keep").

    • na_propagate controls whether NA elements propagate to subsequent elements or lower-priority groups.

  • New phint_has_overlaps() returns a logical vector indicating which elements of a <phinterval> vector overlap with a preceding element. Accepts the same arguments as phint_unoverlap().

    • New phint_any_overlaps() is a fast scalar equivalent to any(phint_has_overlaps(...), na.rm = TRUE).
  • New phint_cumunion(), phint_cumintersect(), phint_symmetric_setdiff() to complete the family of set-operations.

  • New phint_flatten() returns all spans or gaps within an entire phinterval vector as a vector of intervals.

  • New is_span() and is_disjoint() to complement is_hole().

    • is_span() and is_disjoint() test whether each element of a phinterval is contiguous or disjoint respectively.
  • phint_sift() now keeps or discards spans with lengths in [min_length, max_length], instead of discarding instantaneous spans only.

Bug fixes

  • phint_setdiff() no longer returns a malformed phinterval when phint2 contains instants (#3).

  • phint_invert() no longer returns a malformed phinterval when phint contains instants (#9).

Breaking changes

  • phint_unnest() now always returns a dataframe with columns key, start, end, and size, instead of optionally including a size column.

The keep_size argument has been removed from phint_unnest() and the function signature has been revised:

# Old Usage
phint_unnest(phint, hole_to = c("drop", "na"), keep_size = FALSE, key = NULL)

# New Usage
phint_unnest(phint, key = NULL, hole_to = c("na", "drop"))

The return type of the *_squash() variants is now always a scalar <phinterval> vector, meaning it is safe to use within dplyr::summarize(). This includes cases where the phint argument of phint_squash() or the start, end arguments of datetime_squash() are empty as the empty_to = "empty" option has been removed from the empty_to argument.

The return type of the *_squash_by() variants is now always a tibble() with columns by and phint. Additionally, the keep_by argument has been removed from these variants.

# Old Usage
phint_squash(
  phint,
  by = NULL,
  na.rm = TRUE,
  empty_to = c("hole", "na", "empty"),
  order_by = FALSE,
  keep_by = FALSE
)

# New Usage
phint_squash(
  phint,
  na_rm = TRUE,
  empty_to = c("hole", "na")
)

phint_squash_by(
  phint,
  by,
  na_rm = TRUE,
  empty_to = c("hole", "na"),
  order_by = TRUE
)
  • phint_sift() now has additional arguments min_length, max_length, and action.

    • The previous version of phint_sift() (usage phint_sift(phint)) was re-named to phint_discard_instants().

    • Calling phint_sift(phint) without additional arguments now raises an error.

phinterval 1.0.0

CRAN release: 2026-02-03

  • Initial CRAN submission.