phinterval (development version)
Features
-
New
phint_cumunion(),phint_cumintersect(),phint_symmetric_setdiff()to complete the family of set-operations.phint_cumunion()andphint_cumintersect()take the cumulative union and intersection of a phinterval respectively.phint_symmetric_setdiff()takes the symmetric set-difference of two phintervals.
-
New
phint_flatten()returns all spans or gaps within an entire phinterval vector as a vector of intervals.- New
datetime_flatten()returns spans or gaps within a vector of spans defined bystartandendpoints (see alsodatetime_squash()).
- New
-
New
is_span()andis_disjoint()to complementis_hole().-
is_span()andis_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.- The previous version of
phint_sift()was re-named tophint_discard_instants().
- The previous version of
Bug fixes
phint_setdiff()no longer returns a malformed phinterval whenphint2contains instants (#3).phint_invert()no longer returns a malformed phinterval whenphintcontains instants (#9).
Breaking changes
-
phint_unnest()now always returns a dataframe with columnskey,start,end, andsize, instead of optionally including asizecolumn.
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"))
-
phint_squash()anddatetime_squash()have been split into two functions (#13).phint_squash()anddatetime_squash()now always squash intervals into a length-1<phinterval>.phint_squash_by()anddatetime_squash_by()squash intervals within groups defined by thebyargument.The
order_byargument ofphint_squash_by()anddatetime_squash_by()now defaults toTRUE, to match the behavior ofdplyr::group_by().The
na.rmargument of the squash functions has been renamed tona_rm(#19).
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 argumentsmin_length,max_length, andaction.The previous version of
phint_sift()(usagephint_sift(phint)) was re-named tophint_discard_instants().Calling
phint_sift(phint)without additional arguments now raises an error.
