Essentially a slight tweak to the base R summary.

num_summary(x, digits = 1, extra = FALSE)

Arguments

x

A numeric or logical variable

digits

Argument to round. Default is 1.

extra

Add things like number distinct, number of zeros, and more as I think of them.

Value

A data.frame containing those values.

Details

Takes a numeric variable and provides sample size, mean, standard deviation, min, first quartile, median, third quartile, and max, and number of NAs. Extras include the number of distinct values, and the number of zeros.

Examples

library(tidyext) num_summary(c(1:10, NA))
#> # A tibble: 1 x 9 #> N Mean SD Min Q1 Median Q3 Max `% Missing` #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 10 5.5 3 1 3.2 5.5 7.8 10 9
num_summary(c('1','2','3'))
#> # A tibble: 1 x 9 #> N Mean SD Min Q1 Median Q3 Max `% Missing` #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 3 2 1 1 1.5 2 2.5 3 0