tidy_summary | R Documentation |
type
column indicates whether the data is numeric, character, factor, or logical.This function calculates the five-number summary (minimum, first quartile, median, third quartile, maximum) for specified numeric columns in a data frame and returns the results in a long format. It also handles categorical, factor, and logical columns by counting the occurrences of each level or value, and includes the results in the summary. The type
column indicates whether the data is numeric, character, factor, or logical.
tidy_summary(df, columns = names(df), ...)
df |
A data frame containing the data. The data frame must have at least one row. |
columns |
Unquoted column names or tidyselect helpers specifying the columns for which to calculate the summary. Defaults to call columns in the inputted data frame. |
... |
Additional arguments passed to the |
A tibble in long format with columns:
The name of the column.
The number of non-missing values in the column for numeric variables and the number of non-missing values in the group for categorical, factor, and logical columns.
The group level or value for categorical, factor, and logical columns.
The type of data in the column (numeric, character, factor, or logical).
The minimum value (for numeric columns).
The first quartile (for numeric columns).
The mean value (for numeric columns).
The median value (for numeric columns).
The third quartile (for numeric columns).
The maximum value (for numeric columns).
The standard deviation (for numeric columns).
# Example usage with a simple data frame
df <- tibble::tibble(
category = factor(c("A", "B", "A", "C")),
int_values = c(10, 15, 7, 8),
num_values = c(8.2, 0.3, -2.1, 5.5),
one_missing_value = c(NA, 1, 2, 3),
flag = c(TRUE, FALSE, TRUE, TRUE)
)
# Specify columns
tidy_summary(df, columns = c(category, int_values, num_values, flag))
# Defaults to full data frame (note an error will be given without
# specifying `na.rm = TRUE` since `one_missing_value` has an `NA`)
tidy_summary(df, na.rm = TRUE)
# Example with additional arguments for quantile functions
tidy_summary(df, columns = c(one_missing_value), na.rm = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.