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.642  -3.67 0.000241 0.261  -0.642 
#>  2 1              2 -1.19   -3.53 0.000666 0.118  -1.19  
#>  3 1              3  1.70   -3.39 0.00163  0.955   1.70  
#>  4 1              4 -0.305  -3.25 0.00356  0.380  -0.305 
#>  5 1              5 -0.632  -3.11 0.00693  0.264  -0.632 
#>  6 1              6  1.03   -2.98 0.0121   0.849   1.03  
#>  7 1              7 -1.03   -2.84 0.0188   0.152  -1.03  
#>  8 1              8  0.328  -2.70 0.0265   0.628   0.328 
#>  9 1              9  0.0496 -2.56 0.0340   0.520   0.0496
#> 10 1             10 -1.29   -2.42 0.0406   0.0990 -1.29  
#> # ℹ 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")