set_operations | R Documentation |
Perform set operations on a pair of [number_line]
s.
union_number_lines(x, y)
intersect_number_lines(x, y)
subtract_number_lines(x, y)
x |
|
y |
|
union_number_lines()
- Combined the range of x
and that of y
intersect_number_line()
- Subset of x
that overlaps with y
and vice versa
subtract_number_lines()
- Subset of x
that does not overlap with y
and vice versa.
The direction
of the returned [number_line]
will be that of the widest one (x
or y
).
If x
and y
have the same length, it'll be an "increasing"
direction.
If x
and y
do not overlap, NA
("NA ?? NA"
) is returned.
[number_line]
; list
number_line
; overlaps
nl_1 <- c(number_line(1, 5), number_line(1, 5), number_line(5, 9))
nl_2 <- c(number_line(1, 2), number_line(2, 3), number_line(0, 6))
# Union
nl_1; nl_2; union_number_lines(nl_1, nl_2)
nl_3 <- number_line(as.Date(c("01/01/2020", "03/01/2020","09/01/2020"), "%d/%m/%Y"),
as.Date(c("09/01/2020", "09/01/2020","25/12/2020"), "%d/%m/%Y"))
nl_4 <- number_line(as.Date(c("04/01/2020","01/01/2020","01/01/2020"), "%d/%m/%Y"),
as.Date(c("05/01/2020","05/01/2020","03/01/2020"), "%d/%m/%Y"))
# Intersect
nl_3; nl_4; intersect_number_lines(nl_3, nl_4)
# Subtract
nl_3; nl_4; subtract_number_lines(nl_3, nl_4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.