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.434 -3.49 0.000313 0.668    0.434
#>  2 1              2  0.922 -3.36 0.000893 0.822    0.922
#>  3 1              3  1.07  -3.23 0.00225  0.858    1.07 
#>  4 1              4 -0.450 -3.11 0.00502  0.326   -0.450
#>  5 1              5  0.614 -2.98 0.00990  0.731    0.614
#>  6 1              6 -0.523 -2.85 0.0173   0.301   -0.523
#>  7 1              7  0.621 -2.73 0.0269   0.733    0.621
#>  8 1              8  0.659 -2.60 0.0374   0.745    0.659
#>  9 1              9 -2.43  -2.47 0.0473   0.00749 -2.43 
#> 10 1             10 -0.232 -2.35 0.0552   0.408   -0.232
#> # ℹ 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")