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.05   -3.13 0.000238 0.148 -1.05  
#>  2 1              2 -0.0954 -3.01 0.000596 0.462 -0.0954
#>  3 1              3  0.446  -2.88 0.00135  0.672  0.446 
#>  4 1              4 -0.356  -2.76 0.00277  0.361 -0.356 
#>  5 1              5 -0.665  -2.64 0.00518  0.253 -0.665 
#>  6 1              6  1.34   -2.52 0.00888  0.911  1.34  
#>  7 1              7  1.04   -2.40 0.0140   0.851  1.04  
#>  8 1              8 -1.12   -2.27 0.0208   0.132 -1.12  
#>  9 1              9 -0.249  -2.15 0.0292   0.402 -0.249 
#> 10 1             10  0.945  -2.03 0.0397   0.828  0.945 
#> # ℹ 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")