library(TidyDensity)
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.825 -3.19 0.000448 0.5 -0.788
#> 2 1 2 0.450 -3.04 0.00124 0.508 -0.0411
#> 3 1 3 -0.696 -2.89 0.00308 0.516 -0.698
#> 4 1 4 0.507 -2.73 0.00689 0.524 -0.0108
#> 5 1 5 0.691 -2.58 0.0139 0.533 0.0858
#> 6 1 6 1.15 -2.43 0.0256 0.541 0.337
#> 7 1 7 1.19 -2.28 0.0431 0.549 0.357
#> 8 1 8 1.67 -2.13 0.0667 0.557 0.641
#> 9 1 9 2.90 -1.98 0.0961 0.565 Inf
#> 10 1 10 -0.740 -1.82 0.130 0.573 -0.728
#> # … with 40 more rows
#> # ℹ Use `print(n = ...)` to see more rows
An example plot of the tidy_normal
data.
<- tidy_normal(.n = 100, .num_sims = 6)
tn
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.
<- tidy_normal(.n = 100, .num_sims = 20)
tn
tidy_autoplot(tn, .plot_type = "density")
tidy_autoplot(tn, .plot_type = "quantile")
tidy_autoplot(tn, .plot_type = "probability")
tidy_autoplot(tn, .plot_type = "qq")