tidysummary: Create a tidy summary of a data frame

View source: R/tidysummary.R

tidysummaryR Documentation

Create a tidy summary of a data frame

Description

Create a summary (small, medium or large) of a data frame.

Usage

tidysummary(x, size = "small", digits = 2)

Arguments

x

a data.frame to generate a summary for. Can also be an atomic vector (numeric, factor, boolean etc.).

size

how large the summary should be. Either small, medium or large (or simply s, m or l).

digits

the number of decimal places for rounding. Can be an integer or NULL (no rounding).

Details

The returned data frame has the following columns:

column Name of the column
n Number of observations
class Data type
min Minimum value
max Maximum value
mean Mean value
sd Standard deviation
unique Number of unique values (includes NA)
median Median value
na Number of NAs (missing values)
mode Most frequent value
quant25 25 percent quantile
quant75 75 percent quantile
levels Number of factor levels (only relevant for factors)
head Top (first) value of the data frame
tail Bottom (last) value of the data frame
se Standard error
skewness Skewness
kurtosis Kurtosis
bytes Size in bytes of the memory usage of the column

Note:

  • For character vectors, the text length will be used to calculate the statistics.

  • Missing values will be automatically removed before any statistical summaries are calculated

  • Statistical summaries are produced using base R functions with defaults. Kurtosis and skewness is produced using code adapted from the moments package (https://cran.r-project.org/web/packages/moments/index.html).

Value

A data frame with one row per column.

See Also

to_markdown(), to_latex(), to_html(), to_json(), to_csv(), to_excel()

Examples

# Summary for data frame
tidysummary(iris)
tidysummary(iris, "medium")
tidysummary(iris, digits=2)

# Summary for atomic vector
tidysummary(iris$Sepal.Length, "large")

# Convert summary to Markdown
output <- tidysummary(iris)
to_markdown(output)


peterdalle/tidysummary documentation built on March 27, 2022, 4:30 p.m.