Getting Started with TidyDensity

library(TidyDensity)

Example

This is a basic example which shows you how easy it is to generate data with {TidyDensity}:

library(TidyDensity)
library(dplyr)
library(ggplot2)

tidy_normal()
#> # A tibble: 50 x 7
#>    sim_number     x       y    dx       dy     p        q
#>    <fct>      <int>   <dbl> <dbl>    <dbl> <dbl>    <dbl>
#>  1 1              1 -2.59   -3.60 0.000269 0.5   -Inf    
#>  2 1              2 -2.10   -3.46 0.000849 0.508   -2.05 
#>  3 1              3  0.831  -3.32 0.00227  0.516   -1.74 
#>  4 1              4 -0.632  -3.18 0.00517  0.524   -1.54 
#>  5 1              5 -0.114  -3.05 0.0101   0.533   -1.39 
#>  6 1              6  1.31   -2.91 0.0169   0.541   -1.27 
#>  7 1              7 -0.315  -2.77 0.0249   0.549   -1.16 
#>  8 1              8 -0.688  -2.63 0.0331   0.557   -1.07 
#>  9 1              9  0.0416 -2.50 0.0407   0.565   -0.981
#> 10 1             10 -0.116  -2.36 0.0474   0.573   -0.901
#> # ... with 40 more rows

An example plot of the tidy_normal data.

tn <- tidy_normal(.n = 100, .num_sims = 6)

tidy_autoplot(tn, .plot_type = "density")

tidy_autoplot(tn, .plot_type = "quantile")

tidy_autoplot(tn, .plot_type = "probability")

tidy_autoplot(tn, .plot_type = "qq")

We can also take a look at the plots when the number of simulations is greater than nine. This will automatically turn off the legend as it will become too noisy.

tn <- tidy_normal(.n = 100, .num_sims = 20)

tidy_autoplot(tn, .plot_type = "density")

tidy_autoplot(tn, .plot_type = "quantile")

tidy_autoplot(tn, .plot_type = "probability")

tidy_autoplot(tn, .plot_type = "qq")