This function provides a summary of each column in a data frame, generating different statistics based on the type of data (numeric, factor, character, logical, or other). It returns a tibble with the variable names and associated summary statistics, categorized by their data type.

summarize_table(df)

Arguments

df

A data frame containing the variables to be summarized.

Value

A tibble with summary statistics for each variable in the input data frame. The summary includes:

Type

The data type of the variable (Numeric, Factor, Character, Logical, Other).

Mean

The mean of the numeric variables (if applicable).

Median

The median of the numeric variables (if applicable).

SD

The standard deviation of the numeric variables (if applicable).

Min

The minimum value of the numeric variables (if applicable).

Max

The maximum value of the numeric variables (if applicable).

Levels

The number of levels for factor variables (if applicable).

Unique

The number of unique values for character or factor variables.

Most_Common

The most frequent value for character or factor variables.

Frequency

The frequency of the most common value for character or factor variables.

True_Count

The number of TRUE values for logical variables.

False_Count

The number of FALSE values for logical variables.

NA_Count

The number of missing values for each variable.

Examples

summarize_table(mtcars)
#> # A tibble: 11 × 8
#>   Variable Type      Mean Median      SD   Min    Max NA_Count
#>   <chr>    <chr>    <dbl>  <dbl>   <dbl> <dbl>  <dbl>    <int>
#> 1 mpg      Numeric  20.1   19.2    6.03  10.4   33.9         0
#> 2 cyl      Numeric   6.19   6      1.79   4      8           0
#> 3 disp     Numeric 231.   196.   124.    71.1  472           0
#> 4 hp       Numeric 147.   123     68.6   52    335           0
#> 5 drat     Numeric   3.60   3.70   0.535  2.76   4.93        0
#> 6 wt       Numeric   3.22   3.32   0.978  1.51   5.42        0
#> # ℹ 5 more rows