describe_all | R Documentation |
This function extends {describe}
by applying to it all
columns of the specified class(es) in a data frame using functional
programming tools from the purrr package (e.g. map
).
To obtain a summary of a single variable in a data frame use
describe
instead.
describe_all( data, ..., class = "all", digits = 3, type = 2, na.rm = TRUE, sep = "_", output = c("dt", "tibble") )
data |
A data frame or tibble. |
... |
This special argument accepts any number of unquoted grouping
variable names (also present in the data source) to use for subsetting,
separated by commas, e.g. |
class |
The variable classes in data that you would like summaries for. Either "all" for all classes, or a character vector indicating which combinations of output classes you want. Specifying a subset will save time since summaries are only processed as needed. Options include "d" for dates, "f" for factors, "c" for character, "l" for logical, and "n" for numeric. If only a single class is requested or present in the data after excluding specified grouping variables, a data frame will be returned, otherwise you'll get a list of data frames (1 per summary class). If the only chosen class of variables is not detected in the input data an error will be returned that the class argument needs to be respecified. |
digits |
This determines the number of digits used for rounding of numeric outputs. |
type |
For numeric and integer vectors this determines the type of
skewness and kurtosis calculations to perform. See
|
na.rm |
This determines whether missing values (NAs) should be removed before attempting to calculate summary statistics. |
sep |
A character string to use to separate unique values from their counts ("_" by default). Only applicable to factors and character vectors. |
output |
Output type for each class of variables. dt" for data.table or "tibble" for tibble. |
The output varies as a function of the class of input data/y, referred to as "y" below. Each output type is grouped together in a data frame and returned as a named item of a list, unless there is only one output type, in which case the data frame is returned directly.
For all input variables, the following are returned (part 1):
the total number of cases
number of complete cases
the number of missing values
the proportion of total cases with missing values
In addition to part 1, these measures are provided for dates:
the total number of unique values or levels of y. For dates this tells you how many time points there are
the earliest or minimum date in y
the latest or maximum date in y
In addition to part 1, these measures are provided for factors:
the total number of unique values or levels of y
a logical indicating whether or not y is ordinal
the counts of the top and bottom unique values of y in order of decreasing frequency formatted as "value_count". If there are more than 4 unique values of y, only the top 2 and bottom 2 unique values are shown separated by "...". To get counts for all unique values use counts
or counts_tb
instead.
In addition to part 1, these measures are provided for character/string vectors:
the total number of unique values or levels of y
the minimum number of characters in the values of y
the maximum number of characters in the values of y
the counts of the top and bottom unique values of y in order of decreasing frequency formatted as "value_count". If there are more than 4 unique values of y, only the top 2 and bottom 2 unique values are shown separated by "...". To get counts for all unique values use counts
or counts_tb
instead.
In addition to part 1, these measures are provided for logical vectors:
the total number of y values that are TRUE
the total number of y values that are FALSE
the proportion of y values that are TRUE
In addition to part 1, these measures are provided for numeric variables:
the mean of y
the standard deviation of y
the standard error of the mean of y
the 0th percentile (the minimum) of y
the 25th percentile of y
the 50th percentile (the median) of y
the 25th percentile of y
the 100th percentile (the maximum) of y
the skewness of the distribution of y
the kurtosis of the distribution of y
Craig P. Hutton, craig.hutton@gov.bc.ca
describe
describe_all(mtcars) ## Not run: describe_all(pdata) #all summary types in a list #numeric summary only describe_all(pdata, high_low, output = "dt", class = "n") #numeric and logical summaries only describe_all(pdata, high_low, output = "dt", class = c("n", "l")) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.