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.897 -3.00 0.000460 0.185 -0.897
#>  2 1              2  1.42  -2.87 0.00116  0.922  1.42 
#>  3 1              3 -0.211 -2.75 0.00262  0.416 -0.211
#>  4 1              4  0.341 -2.63 0.00536  0.633  0.341
#>  5 1              5  0.664 -2.50 0.00993  0.747  0.664
#>  6 1              6 -1.19  -2.38 0.0167   0.117 -1.19 
#>  7 1              7  1.10  -2.26 0.0257   0.864  1.10 
#>  8 1              8 -0.374 -2.14 0.0364   0.354 -0.374
#>  9 1              9 -0.185 -2.01 0.0482   0.427 -0.185
#> 10 1             10  1.89  -1.89 0.0610   0.971  1.89 
#> # ℹ 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")