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  2.69    -2.83 0.000791 0.996   2.69   
#>  2 1              2  1.75    -2.70 0.00214  0.960   1.75   
#>  3 1              3 -0.821   -2.56 0.00522  0.206  -0.821  
#>  4 1              4 -1.54    -2.42 0.0115   0.0620 -1.54   
#>  5 1              5 -0.00182 -2.28 0.0228   0.499  -0.00182
#>  6 1              6 -0.658   -2.14 0.0411   0.255  -0.658  
#>  7 1              7 -0.581   -2.01 0.0675   0.281  -0.581  
#>  8 1              8 -0.0223  -1.87 0.101    0.491  -0.0223 
#>  9 1              9 -1.59    -1.73 0.140    0.0557 -1.59   
#> 10 1             10 -1.25    -1.59 0.179    0.106  -1.25   
#> # ℹ 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")