A kind of improved summary

digest(x)

Arguments

x

tibble or vector

Details

For numeric columns, returns a tiny summary. For character/factor columns, returns a count table. For the two previous cases tests if values are constant or unique, respectively. In both cases, returning a tibble would not be useful, but knowing that a character/factor is unique can be useful when making an id column. Also report NA cases, if any. For tibbles, prints a colwise digest.

Examples

# numeric 1:5 %>% digest
#> # A tibble: 3 x 2 #> quantile value #> <chr> <dbl> #> 1 min 1 #> 2 median 3 #> 3 max 5
c(NA, 1:5) %>% digest() # count NA
#> # A tibble: 4 x 2 #> quantile value #> <chr> <dbl> #> 1 <NA> 1 #> 2 min 1 #> 3 median 3 #> 4 max 5
rep(1, 5) %>% digest() # constant
#> [1] "constant (5)"
# factor iris$Species %>% digest
#> # A tibble: 3 x 2 #> level count #> <chr> <int> #> 1 setosa 50 #> 2 versicolor 50 #> 3 virginica 50
c(NA, iris$Species) %>% digest() # count NA
#> # A tibble: 4 x 2 #> quantile value #> <chr> <dbl> #> 1 <NA> 1 #> 2 min 1 #> 3 median 2 #> 4 max 3
factor(rep("a", 5)) %>% digest() # unique
#> # A tibble: 1 x 2 #> level count #> <chr> <int> #> 1 a 5