Set operations for run length encoding <NA>

# S3 method for rle_na
intersect(x, y, ...)

# S3 method for rle_na
union(x, y, ...)

# S3 method for rle_na
setdiff(x, y, ...)

Arguments

x, y

Objects returned by na_rle() or list_of_na_rle().

...

other arguments passed on to methods

Examples

(x <- na_rle(c(1, NA, NA, 4:7, NA, NA, 10:15, NA)))
#> <Run Length Encoding <NA>[3]> #> $lengths: <int> 2 2 1 #> $indices: <int> 2 8 16
(y <- na_rle(c(10, NA, NA, NA, 6:3, NA, 1)))
#> <Run Length Encoding <NA>[2]> #> $lengths: <int> 3 1 #> $indices: <int> 2 9
intersect(x, y)
#> <Run Length Encoding <NA>[2]> #> $lengths: <int> 2 1 #> $indices: <int> 2 9
union(x, y)
#> <Run Length Encoding <NA>[3]> #> $lengths: <int> 3 2 1 #> $indices: <int> 2 8 16
setdiff(x, y)
#> <Run Length Encoding <NA>[2]> #> $lengths: <int> 1 1 #> $indices: <int> 8 16
setdiff(y, x)
#> <Run Length Encoding <NA>[1]> #> $lengths: <int> 1 #> $indices: <int> 4
labels <- c("x", "y", "intersect(x, y)", "union(x, y)", "setdiff(x, y)", "setdiff(y, x)") labels <- factor(labels, levels = labels) lst_na_rle <- vctrs::as_list_of( x, y, intersect(x, y), union(x, y), setdiff(x, y), setdiff(y, x) ) autoplot(lst_na_rle, labels)