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.0690 -2.05 0.000557 0.5   -0.405
#>  2 1              2  0.173  -1.95 0.00153  0.508 -0.206
#>  3 1              3 -0.160  -1.85 0.00375  0.516 -0.483
#>  4 1              4 -1.13   -1.75 0.00829  0.524 -2.29 
#>  5 1              5 -0.169  -1.65 0.0165   0.533 -0.491
#>  6 1              6  0.661  -1.55 0.0300   0.541  0.179
#>  7 1              7  1.06   -1.45 0.0496   0.549  0.515
#>  8 1              8 -0.535  -1.34 0.0758   0.557 -0.851
#>  9 1              9  0.577  -1.24 0.108    0.565  0.112
#> 10 1             10  0.158  -1.14 0.144    0.573 -0.217
#> # … with 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")