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.0917 -3.16 0.000229 0.537  0.0917
#>  2 1              2  0.790  -3.01 0.000639 0.785  0.790 
#>  3 1              3 -0.297  -2.87 0.00156  0.383 -0.297 
#>  4 1              4  1.09   -2.73 0.00337  0.863  1.09  
#>  5 1              5 -0.567  -2.59 0.00642  0.285 -0.567 
#>  6 1              6 -0.702  -2.45 0.0109   0.241 -0.702 
#>  7 1              7  0.608  -2.30 0.0168   0.728  0.608 
#>  8 1              8 -1.27   -2.16 0.0242   0.102 -1.27  
#>  9 1              9 -0.420  -2.02 0.0338   0.337 -0.420 
#> 10 1             10 -0.561  -1.88 0.0476   0.287 -0.561 
#> # ℹ 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")