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  1.39  -3.37 0.000231 0         -Inf    
#>  2 1              2  0.573 -3.23 0.000610 0           -2.05 
#>  3 1              3  2.04  -3.10 0.00144  0           -1.74 
#>  4 1              4  0.540 -2.96 0.00304  0           -1.54 
#>  5 1              5  0.934 -2.83 0.00574  0           -1.39 
#>  6 1              6  1.22  -2.70 0.00977  0           -1.27 
#>  7 1              7  0.950 -2.56 0.0152   0           -1.16 
#>  8 1              8 -0.675 -2.43 0.0217   4.18e-284   -1.07 
#>  9 1              9  0.560 -2.29 0.0293   1.11e-253   -0.981
#> 10 1             10 -0.996 -2.16 0.0382   5.45e-225   -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")