Summarises a dataset using tidyr::gather() and dplyr::summarise().

summarise_all_vars(data)

Arguments

data

dataset

Value

return a tbl_df with one var per row and one column for mean, sd, max, min (all with missings removed), the number of missings, the number of nonmissing values, and the number of distinct values

Examples

data(beavers) summarise_all_vars(beaver1)
#> # A tibble: 4 x 8 #> variable mean sd min max n_miss n_nonmiss n_distinct #> <fct> <dbl> <dbl> <dbl> <dbl> <int> <int> <int> #> 1 day 346. 0.403 346. 347. 0 114 2 #> 2 time 1312. 702. 0. 2350. 0 114 114 #> 3 temp 36.9 0.193 36.3 37.5 0 114 57 #> 4 activ 0.0526 0.224 0. 1.00 0 114 2
beaver1 = dplyr::group_by(beaver1, activ) summarise_all_vars(beaver1)
#> # A tibble: 6 x 9 #> # Groups: variable [?] #> variable activ mean sd min max n_miss n_nonmiss n_distinct #> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <int> <int> #> 1 day 0. 346. 0.405 346. 347. 0 108 2 #> 2 day 1. 346. 0.408 346. 347. 0 6 2 #> 3 time 0. 1286. 694. 0. 2350. 0 108 108 #> 4 time 1. 1783. 737. 340. 2300. 0 6 6 #> 5 temp 0. 36.8 0.175 36.3 37.2 0 108 52 #> 6 temp 1. 37.2 0.167 37.1 37.5 0 6 6