R/tagged_na.R
unique_tagged_na.Rd
These adaptations of base::unique()
, base::duplicated()
,
base::order()
and base::sort()
treats tagged NAs as distinct
values.
unique_tagged_na(x, fromLast = FALSE)
duplicated_tagged_na(x, fromLast = FALSE)
order_tagged_na(
x,
na.last = TRUE,
decreasing = FALSE,
method = c("auto", "shell", "radix"),
na_decreasing = decreasing,
untagged_na_last = TRUE
)
sort_tagged_na(
x,
decreasing = FALSE,
na.last = TRUE,
na_decreasing = decreasing,
untagged_na_last = TRUE
)
a vector
logical indicating if duplication should be considered from the last
if TRUE
, missing values in the data are put last;
if FALSE
, they are put first
should the sort order be increasing or decreasing?
the method to be used, see base::order()
should the sort order for tagged NAs value be
should untagged NA
s be sorted after tagged NA
s?
increasing or decreasing?
x <- c(1, 2, tagged_na("a"), 1, tagged_na("z"), 2, tagged_na("a"), NA)
x %>% print_tagged_na()
#> [1] 1 2 NA(a) 1 NA(z) 2 NA(a) NA
unique(x) %>% print_tagged_na()
#> [1] 1 2 NA(a)
unique_tagged_na(x) %>% print_tagged_na()
#> [1] 1 2 NA(a) NA(z) NA
duplicated(x)
#> [1] FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE
duplicated_tagged_na(x)
#> [1] FALSE FALSE FALSE TRUE FALSE TRUE TRUE FALSE
order(x)
#> [1] 1 4 2 6 3 5 7 8
order_tagged_na(x)
#> [1] 1 4 2 6 3 7 5 8
sort(x, na.last = TRUE) %>% print_tagged_na()
#> [1] 1 1 2 2 NA(a) NA(z) NA(a) NA
sort_tagged_na(x) %>% print_tagged_na()
#> [1] 1 1 2 2 NA(a) NA(a) NA(z) NA