howmany: Count the number of unique values

View source: R/generic_funs.R

howmanyR Documentation

Count the number of unique values

Description

Count the number of unique values

Usage

howmany(x, ...)

## Default S3 method:
howmany(x, ...)

## S3 method for class 'data.frame'
howmany(x, ...)

## S3 method for class 'table'
howmany(x, ...)

Arguments

x

(Object) The object to count.

...

⁠table:⁠ Column names or positions that are passed to dplyr::select().

Methods (by class)

  • howmany(default): Returns the number of unique values in x.

  • howmany(data.frame): Returns a dataframe showing the number of unique values in each column of x.

  • howmany(table): Coerces x to data.frame and passes it to data.frame method.

Authors

Examples

## --- Default method ---

howmany(rep(letters, 3))
#> 26

howmany(letters, LETTERS)
#> 52

## --- Data.frame method ---

howmany(mtcars)

#> mpg cyl disp hp drat wt qsec vs am gear carb
#>  25   3   27 22   22 29   30  2  2    3    6

howmany(mtcars, -(mpg:disp))

#> hp drat wt qsec vs am gear carb
#> 22   22 29   30  2  2    3    6

howmany(mtcars, drat)

#> drat
#>   22

## --- Table method ---

class(Titanic)
#> [1] "table"

howmany(Titanic)

#> Class Sex Age Survived Freq
#>     4   2   2        2   22


DesiQuintans/desiderata documentation built on April 9, 2023, 5:43 a.m.