compact_summary: Compact Summary of a Dataset

View source: R/compact_summary.R

compact_summaryR Documentation

Compact Summary of a Dataset

Description

Produces a compact summary of a data.frame. Each row of the result describes one column of the input with a type-specific synopsis.

Supported types and their summaries:

  • numeric / integer: count of non-NA values, min and max.

  • character: number of unique values, first values listed.

  • factor: number of levels, levels listed.

  • logical: count of non-NA values, counts of TRUE and FALSE.

  • Date: count of non-NA values, date range.

  • POSIXct / POSIXlt: count of non-NA values, datetime range.

  • hms / difftime: count of non-NA values, time range.

Character and factor columns share the same summary layout but report a different type label.

The result has class "compact_summary" and can be converted into a flextable with as_flextable().

Usage

compact_summary(x, show_type = FALSE, show_na = FALSE, max_levels = 10L)

Arguments

x

A data.frame.

show_type

If TRUE, a Type column is added when the object is rendered as a flextable.

show_na

If TRUE, a NA column showing the count of missing values per column is added when rendered as a flextable.

max_levels

Maximum number of levels or unique values displayed for factor and character columns. Additional values are replaced by ", ...".

Value

A data.frame with additional class "compact_summary".

See Also

as_flextable.compact_summary()

Other as_flextable methods: as_flextable.compact_summary(), as_flextable.data.frame(), as_flextable.gam(), as_flextable.glm(), as_flextable.grouped_data(), as_flextable.htest(), as_flextable.kmeans(), as_flextable.lm(), as_flextable.merMod(), as_flextable.pam(), as_flextable.summarizor(), as_flextable.table(), as_flextable.tabular(), as_flextable.tabulator(), as_flextable.xtable()

Examples

z <- compact_summary(iris)
as_flextable(z)

z <- compact_summary(iris, show_type = TRUE, show_na = TRUE)
as_flextable(z)

flextable documentation built on June 2, 2026, 9:08 a.m.