Summarize an object (typically, a variable -column- in a data.frame). This function is intended to be called by summarize_df

summarize_obj(obj, n_top = 7)

Arguments

obj

R object to summarize

n_top

Number of top unique elements to include in the summary

Value

a one-row tibble with information about the object such as class, length (number of elements), number of na, number of unique elements, sum, min, max, mean, median, percentiles, most frequent values

Examples

summarize_obj(letters)
#> # A tibble: 1 × 37
#>   obj_type obj_class obj_label n_obj  n_na  p_na n_uniq p_uniq top1_key top2_key
#>   <chr>    <chr>     <chr>     <int> <dbl> <dbl>  <dbl>  <dbl> <chr>    <chr>   
#> 1 charact… character ""           26     0     0     26      1 a        b       
#> # ℹ 27 more variables: top3_key <chr>, top4_key <chr>, top5_key <chr>,
#> #   top6_key <chr>, top7_key <chr>, top1_count <int>, top2_count <int>,
#> #   top3_count <int>, top4_count <int>, top5_count <int>, top6_count <int>,
#> #   top7_count <int>, top1_count_p <dbl>, top2_count_p <dbl>,
#> #   top3_count_p <dbl>, top4_count_p <dbl>, top5_count_p <dbl>,
#> #   top6_count_p <dbl>, top7_count_p <dbl>, mean <lgl>, sd <lgl>, min <lgl>,
#> #   q25 <lgl>, median <lgl>, q75 <lgl>, max <lgl>, obj_hist <list>
summarize_obj(runif(100))
#> # A tibble: 1 × 37
#>   obj_type obj_class obj_label n_obj  n_na  p_na n_uniq p_uniq top1_key top2_key
#>   <chr>    <chr>     <chr>     <int> <dbl> <dbl>  <dbl>  <dbl> <chr>    <chr>   
#> 1 double   numeric   ""          100     0     0    100      1 0.45012… 0.68765…
#> # ℹ 27 more variables: top3_key <chr>, top4_key <chr>, top5_key <chr>,
#> #   top6_key <chr>, top7_key <chr>, top1_count <int>, top2_count <int>,
#> #   top3_count <int>, top4_count <int>, top5_count <int>, top6_count <int>,
#> #   top7_count <int>, top1_count_p <dbl>, top2_count_p <dbl>,
#> #   top3_count_p <dbl>, top4_count_p <dbl>, top5_count_p <dbl>,
#> #   top6_count_p <dbl>, top7_count_p <dbl>, mean <chr>, sd <chr>, min <chr>,
#> #   q25 <chr>, median <chr>, q75 <chr>, max <chr>, obj_hist <list>