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.08   -3.86 0.000222 0.139 -1.08  
#>  2 1              2  1.30   -3.72 0.000622 0.904  1.30  
#>  3 1              3  1.07   -3.57 0.00152  0.857  1.07  
#>  4 1              4  0.0829 -3.42 0.00327  0.533  0.0829
#>  5 1              5  0.650  -3.27 0.00612  0.742  0.650 
#>  6 1              6  1.05   -3.12 0.0100   0.854  1.05  
#>  7 1              7 -0.314  -2.97 0.0144   0.377 -0.314 
#>  8 1              8 -0.641  -2.83 0.0180   0.261 -0.641 
#>  9 1              9  1.50   -2.68 0.0199   0.933  1.50  
#> 10 1             10  0.581  -2.53 0.0194   0.719  0.581 
#> # ℹ 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")