Learn R Programming

phinterval (version 1.0.0)

n_spans: Count the number of spans in a phinterval

Description

n_spans() counts the number of disjoint time spans in each element of phint.

Usage

n_spans(phint)

# S3 method for default n_spans(phint)

# S3 method for Interval n_spans(phint)

# S3 method for phinterval n_spans(phint)

Value

An integer vector the same length as phint.

Arguments

phint

[phinterval / Interval]

A <phinterval> or <Interval> vector.

Examples

Run this code
# Count spans
y2000 <- interval(as.Date("2000-01-01"), as.Date("2001-01-01"))
y2025 <- interval(as.Date("2025-01-01"), as.Date("2025-01-01"))

n_spans(c(
 phint_union(y2000, y2025),
 phint_intersect(y2000, y2025),
 y2000, y2025
))

Run the code above in your browser using DataLab