Learn R Programming

plyranges (version 1.9.3)

n_distinct: Compute the number of distinct unique values in a vector or List

Description

This is a wrapper to length(unique(x)) or lengths(unique(x)) if x is a List object

Usage

n_distinct(var)

Arguments

var

a vector of values

Value

an integer vector

Examples

Run this code
# NOT RUN {
x <- CharacterList(c("a", "b", "c", "a"),  "d")
n_distinct(x)
n_distinct(unlist(x))
# }

Run the code above in your browser using DataLab