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.218 -2.78 0.000443 0.5 -0.317
#> 2 1 2 -0.330 -2.66 0.00117 0.508 -0.394
#> 3 1 3 0.392 -2.53 0.00275 0.516 0.0840
#> 4 1 4 -0.299 -2.41 0.00584 0.524 -0.372
#> 5 1 5 -0.0765 -2.28 0.0112 0.533 -0.221
#> 6 1 6 -1.19 -2.16 0.0193 0.541 -1.15
#> 7 1 7 0.896 -2.03 0.0304 0.549 0.422
#> 8 1 8 -0.967 -1.91 0.0440 0.557 -0.907
#> 9 1 9 0.391 -1.79 0.0596 0.565 0.0835
#> 10 1 10 0.477 -1.66 0.0767 0.573 0.139
#> # … with 40 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")