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-
NAvalues, min and max.character: number of unique values, first values listed.
factor: number of levels, levels listed.
logical: count of non-
NAvalues, counts ofTRUEandFALSE.Date: count of non-
NAvalues, date range.POSIXct / POSIXlt: count of non-
NAvalues, datetime range.hms / difftime: count of non-
NAvalues, 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().
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
", ...".
See also
as_flextable.compact_summary()
Other as_flextable methods:
as_flextable(),
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)
Column
N
Values
Sepal.Length
150
Min: 4.3, Max: 7.9
Sepal.Width
150
Min: 2.0, Max: 4.4
Petal.Length
150
Min: 1.0, Max: 6.9
Petal.Width
150
Min: 0.1, Max: 2.5
Species
3
'setosa', 'versicolor', 'virginica'
z <- compact_summary(iris, show_type = TRUE, show_na = TRUE)
as_flextable(z)
Column
Type
N
NA
Values
Sepal.Length
numeric
150
0
Min: 4.3, Max: 7.9
Sepal.Width
numeric
150
0
Min: 2.0, Max: 4.4
Petal.Length
numeric
150
0
Min: 1.0, Max: 6.9
Petal.Width
numeric
150
0
Min: 0.1, Max: 2.5
Species
factor
3
0
'setosa', 'versicolor', 'virginica'
