Learn R Programming

cards (version 0.9.0)

.unique_and_sorted: ARD-flavor of unique()

Description

Essentially a wrapper for unique(x) sorted in the C locale with NA levels removed. Character values are ordered with order(method = "radix"), so the result is independent of the session locale and matches the ordering dplyr::arrange() applies. For factors, all levels are returned even if they are unobserved. Similarly, logical vectors always return c(TRUE, FALSE), even if both levels are not observed.

Usage

.unique_and_sorted(x, useNA = c("no", "always"))

Value

a vector

Arguments

x

(any)
a vector

Examples

Run this code
cards:::.unique_and_sorted(factor(letters[c(5, 5:1)], levels = letters))

cards:::.unique_and_sorted(c(FALSE, TRUE, TRUE, FALSE))

cards:::.unique_and_sorted(c(5, 5:1))

Run the code above in your browser using DataLab