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.332 -3.64 0.000240 0.630  0.332
#>  2 1              2  0.307 -3.51 0.000650 0.621  0.307
#>  3 1              3 -0.927 -3.37 0.00156  0.177 -0.927
#>  4 1              4  0.841 -3.24 0.00333  0.800  0.841
#>  5 1              5  0.785 -3.11 0.00631  0.784  0.785
#>  6 1              6  1.76  -2.97 0.0107   0.961  1.76 
#>  7 1              7  0.859 -2.84 0.0161   0.805  0.859
#>  8 1              8  0.560 -2.71 0.0221   0.712  0.560
#>  9 1              9 -1.03  -2.57 0.0279   0.151 -1.03 
#> 10 1             10  0.740 -2.44 0.0329   0.770  0.740
#> # ℹ 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")