Skip to contents

Computes a one-row, NA-aware diagnostic summary for one vector. Numeric vectors receive robust and classical statistics, outlier counts, and a normality diagnostic. Non-numeric vectors receive safe type, missingness, uniqueness, and mode summaries.

Usage

summarize_vector(x, name = NA_character_, alpha = 0.05, digits = NULL)

Arguments

x

A vector.

name

Optional variable name to store in the variable column.

alpha

Significance level for the normality decision. Defaults to 0.05.

digits

Optional number of digits used to round numeric output. By default, numeric values are not rounded.

Value

A one-row data.frame with summary statistics and diagnostics.

Examples

summarize_vector(c(1, 2, 2, NA, 5), name = "score")
#>   variable    type n n_complete n_missing missing_pct n_unique mode mode_count
#> 1    score numeric 5          4         1          20        3    2          2
#>   mode_ties mean median       sd variance minimum  q25  q75 maximum range iqr
#> 1     FALSE  2.5      2 1.732051        3       1 1.75 2.75       5     4   1
#>      mad  skewness excess_kurtosis outlier_count outlier_pct normality_test
#> 1 0.7413 0.5773503       -1.770833             1          25   Shapiro-Wilk
#>   normality_statistic normality_p_value normality_alpha
#> 1           0.8397017         0.1945345            0.05
#>              normality_decision warning
#> 1 No evidence against normality    <NA>
summarize_vector(factor(c("control", "treatment", "control")))
#>   variable   type n n_complete n_missing missing_pct n_unique    mode
#> 1     <NA> factor 3          3         0           0        2 control
#>   mode_count mode_ties mean median sd variance minimum q25 q75 maximum range
#> 1          2     FALSE   NA     NA NA       NA      NA  NA  NA      NA    NA
#>   iqr mad skewness excess_kurtosis outlier_count outlier_pct normality_test
#> 1  NA  NA       NA              NA             0          NA           <NA>
#>   normality_statistic normality_p_value normality_alpha normality_decision
#> 1                  NA                NA            0.05         Not tested
#>                                                warning
#> 1 Normality requires at least 3 finite numeric values.