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

View source: R/ranges-eval.R

n_distinctR Documentation

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

x <- CharacterList(c("a", "b", "c", "a"),  "d")
n_distinct(x)
n_distinct(unlist(x))

sa-lee/plyranges documentation built on April 15, 2024, 12:25 p.m.