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 -0.730   -3.48 0.000205 0.5   -Inf    
#>  2 1              2  0.210   -3.32 0.000595 0.508   -2.05 
#>  3 1              3 -0.816   -3.15 0.00150  0.516   -1.74 
#>  4 1              4  0.366   -2.99 0.00327  0.524   -1.54 
#>  5 1              5  0.879   -2.82 0.00627  0.533   -1.39 
#>  6 1              6 -0.542   -2.66 0.0106   0.541   -1.27 
#>  7 1              7  0.643   -2.49 0.0160   0.549   -1.16 
#>  8 1              8 -0.00589 -2.32 0.0223   0.557   -1.07 
#>  9 1              9 -0.745   -2.16 0.0297   0.565   -0.981
#> 10 1             10 -0.601   -1.99 0.0397   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")