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 × 7
#>    sim_number     x       y    dx       dy      p       q
#>    <fct>      <int>   <dbl> <dbl>    <dbl>  <dbl>   <dbl>
#>  1 1              1  1.16   -3.82 0.000358 0.876   1.16  
#>  2 1              2 -0.455  -3.65 0.00103  0.325  -0.455 
#>  3 1              3 -0.266  -3.47 0.00257  0.395  -0.266 
#>  4 1              4 -0.434  -3.30 0.00562  0.332  -0.434 
#>  5 1              5  1.48   -3.12 0.0108   0.931   1.48  
#>  6 1              6  1.67   -2.95 0.0184   0.953   1.67  
#>  7 1              7  2.49   -2.77 0.0279   0.994   2.49  
#>  8 1              8 -1.40   -2.60 0.0383   0.0810 -1.40  
#>  9 1              9  0.0453 -2.42 0.0490   0.518   0.0453
#> 10 1             10 -0.821  -2.25 0.0602   0.206  -0.821 
#> # ℹ 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")