Tidy Distribution Summary Statistics Tibble — tidy_distribution_summary_tbl • TidyDensity
Description: This function returns a summary statistics tibble. It will use the y column from the tidy_ distribution function.

Skip to contents

# Tidy Distribution Summary Statistics Tibble

Source: `R/tidy_distribution_summary_tbl.R`
`tidy_distribution_summary_tbl.Rd`

This function returns a summary statistics tibble. It will use the y column from the `tidy_` distribution function.

## Usage

    tidy_distribution_summary_tbl(.data, ...)

## Arguments

.data

  The data that is going to be passed from a a `tidy_` distribution function.

...

  This is the grouping variable that gets passed to `dplyr::group_by()` and `dplyr::select()`.

## Value

A summary stats tibble

## Details

This function takes in a `tidy_` distribution table and will return a tibble of the following information:

- `sim_number`

- `mean_val`

- `median_val`

- `std_val`

- `min_val`

- `max_val`

- `skewness`

- `kurtosis`

- `range`

- `iqr`

- `variance`

- `ci_hi`

- `ci_lo`

The kurtosis and skewness come from the package `healthyR.ai`

## Author

Steven P. Sanderson II, MPH

## Examples

    library(dplyr)
    #> Warning: package 'dplyr' was built under R version 4.2.3
    #>
    #> Attaching package: 'dplyr'
    #> The following objects are masked from 'package:stats':
    #>
    #>     filter, lag
    #> The following objects are masked from 'package:base':
    #>
    #>     intersect, setdiff, setequal, union

    tn <- tidy_normal(.num_sims = 5)
    tb <- tidy_beta(.num_sims = 5)

    tidy_distribution_summary_tbl(tn)
    #> # A tibble: 1 × 12
    #>   mean_val median_val std_val min_val max_val skewness kurtosis range   iqr
    #>      <dbl>      <dbl>   <dbl>   <dbl>   <dbl>    <dbl>    <dbl> <dbl> <dbl>
    #> 1   0.0531      0.111    1.01   -2.66    3.25    0.128     3.05  5.90  1.35
    #> # ℹ 3 more variables: variance <dbl>, ci_low <dbl>, ci_high <dbl>
    tidy_distribution_summary_tbl(tn, sim_number)
    #> # A tibble: 5 × 13
    #>   sim_number mean_val median_val std_val min_val max_val skewness kurtosis range
    #>   <fct>         <dbl>      <dbl>   <dbl>   <dbl>   <dbl>    <dbl>    <dbl> <dbl>
    #> 1 1            0.235       0.235   1.03    -2.47    3.25    0.150     3.79  5.72
    #> 2 2           -0.166      -0.209   0.842   -2.34    1.50   -0.254     2.93  3.85
    #> 3 3            0.124       0.188   0.851   -1.55    2.04    0.233     2.65  3.60
    #> 4 4           -0.0756     -0.117   1.17    -2.37    2.71    0.377     2.77  5.08
    #> 5 5            0.148       0.284   1.11    -2.66    2.30   -0.123     2.41  4.96
    #> # ℹ 4 more variables: iqr <dbl>, variance <dbl>, ci_low <dbl>, ci_high <dbl>

    data_tbl <- tidy_combine_distributions(tn, tb)

    tidy_distribution_summary_tbl(data_tbl)
    #> # A tibble: 1 × 12
    #>   mean_val median_val std_val min_val max_val skewness kurtosis range   iqr
    #>      <dbl>      <dbl>   <dbl>   <dbl>   <dbl>    <dbl>    <dbl> <dbl> <dbl>
    #> 1    0.275      0.336   0.778   -2.66    3.25   -0.516     4.65  5.90 0.724
    #> # ℹ 3 more variables: variance <dbl>, ci_low <dbl>, ci_high <dbl>
    tidy_distribution_summary_tbl(data_tbl, dist_type)
    #> # A tibble: 2 × 13
    #>   dist_type mean_val median_val std_val  min_val max_val skewness kurtosis range
    #>   <fct>        <dbl>      <dbl>   <dbl>    <dbl>   <dbl>    <dbl>    <dbl> <dbl>
    #> 1 Gaussian…   0.0531      0.111   1.01  -2.66      3.25    0.128      3.05 5.90
    #> 2 Beta c(1…   0.497       0.493   0.304  0.00583   0.999   0.0281     1.66 0.993
    #> # ℹ 4 more variables: iqr <dbl>, variance <dbl>, ci_low <dbl>, ci_high <dbl>