# for factors:
x = factor(c(letters[1:2], NA), levels = letters[1:3])
distinct_values(x)
distinct_values(x, na_rm = FALSE)
distinct_values(x, drop = FALSE)
distinct_values(x, drop = FALSE, na_rm = FALSE)
# for logicals:
distinct_values(TRUE, drop = FALSE)
# for numerics:
distinct_values(sample(1:3, 10, replace = TRUE))
Run the code above in your browser using DataLab