counts_tb_all: Obtain the top and bottom "n" counts for unique values of all...

View source: R/counts.R

counts_tb_allR Documentation

Obtain the top and bottom "n" counts for unique values of all variables in a data frame.

Description

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.

Usage

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(s)

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

See Also

counts_all, counts_tb, counts

Examples

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

counts_tb_all(df) #(up to) the top & bottom 10 values

#the most & least common values of all variables in \code{data}
counts_tb_all(df, n = 1)

#the top 5 most & least common unique values for all variables in  \code{data}
counts_tb_all(df, n = 5)


bcgov/elucidate documentation built on Sept. 3, 2022, 7:16 p.m.