counts_all | R Documentation |
counts_all
is an extension of counts
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_all(data, n = "all", order = c("d", "a", "i"), sep = "_", na.rm = TRUE)
data |
A data frame (required). |
n |
The number of unique values you want frequency counts for. Default is "all". |
order |
"d" for descending/decreasing order. "a" or "i" for ascending/increasing order. |
sep |
A character string to use to separate unique values from their counts ("_" by default). |
na.rm |
Should missing values be omitted (TRUE/FALSE)? |
A list of character vectors of the unique value frequency counts for each variable of the input data frame sorted in the chosen order. Return values are structured as "value_count", where the "_" portion takes on the value of the sep argument. Returning a character vector makes subsequent manipulation with stringr and other tidyverse tools fairly easily.
Craig P. Hutton, Craig.Hutton@gov.bc.ca
table
, sort
, map
#using a numeric vector data <- data(mtcars) #all unique values of all variables in \code{data} in order of descending frequency counts_all(data) #the most common values of all variables in \code{data} counts_all(data, n = 1) #the top 5 most common unique values for all variables in \code{data} counts_all(data, n = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.