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  0.214 -3.69 0.000234 0.585    0.214
#>  2 1              2  1.09  -3.53 0.000741 0.862    1.09 
#>  3 1              3 -2.54  -3.37 0.00198  0.00549 -2.54 
#>  4 1              4 -1.01  -3.21 0.00446  0.157   -1.01 
#>  5 1              5 -1.15  -3.06 0.00849  0.124   -1.15 
#>  6 1              6 -0.705 -2.90 0.0137   0.240   -0.705
#>  7 1              7 -0.307 -2.74 0.0187   0.380   -0.307
#>  8 1              8 -0.414 -2.58 0.0223   0.339   -0.414
#>  9 1              9  0.586 -2.43 0.0246   0.721    0.586
#> 10 1             10 -1.47  -2.27 0.0282   0.0713  -1.47 
#> # ℹ 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")