This generic function calculates how many unique observations are in a vector It is identical to length(unique(x)). However, this function can be used on either a vector or a data frame with a specified column. See the examples for more details.

how_many(x, ...)

Arguments

x

Object such as a data.frame or vector

...

Additional arguments passed to or from other methods.

Value

An integer indicating how many unique observations are in the object.

Examples

how_many(mtcars$cyl) # Pass in vector directly
#> [1] 3
how_many(mtcars, "cyl") # Subset dataframe with a character string for column name
#> [1] 3
how_many(mtcars, cyl) # Subset dataframe without needing to quote the column name
#> [1] 3