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.0562 -3.28 0.000376 0.5   -0.0288
#>  2 1              2  1.16   -3.15 0.000981 0.508  0.687 
#>  3 1              3 -0.404  -3.01 0.00233  0.516 -0.311 
#>  4 1              4 -1.13   -2.87 0.00505  0.524 -0.826 
#>  5 1              5  0.183  -2.73 0.00998  0.533  0.0476
#>  6 1              6 -1.15   -2.59 0.0181   0.541 -0.848 
#>  7 1              7 -0.527  -2.45 0.0300   0.549 -0.389 
#>  8 1              8  0.672  -2.32 0.0458   0.557  0.349 
#>  9 1              9 -1.18   -2.18 0.0647   0.565 -0.872 
#> 10 1             10 -1.61   -2.04 0.0851   0.573 -1.35  
#> # ... 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")