counts_tb_all is an extension of counts_tb that returns the most or least common unique value(s) for each column vector of a data frame. Also useful for identifying data entry errors or rare cases. For complex use cases see describe_all.

counts_tb_all(data, n = 10, sep = "_", na.rm = TRUE)

Arguments

data

A data frame (required).

n

The number of top & bottom unique values you want frequency counts for. Default is 10 (fewer than "n" will be shown if there aren't "n" unique values).

sep

This only needs to be modified if some values to be counted contain an underscore, in which case you should change it to a character string that is not present in any of the values in the data source.

na.rm

Should missing values be omitted (TRUE/FALSE)?

Value

A list of data frames of the top and bottom counts for each variable of the input data frame. Return value columns are "top_v" = top value, "top_n" = count of the top value in the same row of the adjacent top_v column, "bot_v" = bottom value, & "bot_n" = count of the bottom value in the same row of the adjacent bot_v column.

Author

Craig P. Hutton, Craig.Hutton@gov.bc.ca

Examples

#using the mtcars data
df <- data(mtcars)

counts_tb_all(df) #(up to) the top & bottom 10 values
#> [[1]]
#>    top_v top_n  bot_v bot_n
#> 1 mtcars     1 mtcars     1
#> 

#the most & least common values of all variables in \code{data}
counts_tb_all(df, n = 1)
#> [[1]]
#>    top_v top_n  bot_v bot_n
#> 1 mtcars     1 mtcars     1
#> 

#the top 5 most & least common unique values for all variables in  \code{data}
counts_tb_all(df, n = 5)
#> [[1]]
#>    top_v top_n  bot_v bot_n
#> 1 mtcars     1 mtcars     1
#>