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.487 -3.15 0.000458 0.313  -0.487
#>  2 1              2 -0.731 -3.01 0.00128  0.232  -0.731
#>  3 1              3  0.681 -2.87 0.00319  0.752   0.681
#>  4 1              4 -0.870 -2.74 0.00705  0.192  -0.870
#>  5 1              5 -0.402 -2.60 0.0138   0.344  -0.402
#>  6 1              6 -0.717 -2.46 0.0242   0.237  -0.717
#>  7 1              7  0.576 -2.32 0.0379   0.718   0.576
#>  8 1              8 -1.75  -2.19 0.0533   0.0398 -1.75 
#>  9 1              9  0.852 -2.05 0.0677   0.803   0.852
#> 10 1             10  0.679 -1.91 0.0789   0.751   0.679
#> # ℹ 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")