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.946 -3.09 0.000253 0.5 -0.765
#> 2 1 2 -1.36 -2.95 0.000762 0.508 -1.10
#> 3 1 3 0.611 -2.81 0.00199 0.516 0.125
#> 4 1 4 -0.980 -2.67 0.00453 0.524 -0.789
#> 5 1 5 -0.890 -2.52 0.00903 0.533 -0.726
#> 6 1 6 -1.35 -2.38 0.0160 0.541 -1.10
#> 7 1 7 1.05 -2.24 0.0258 0.549 0.364
#> 8 1 8 -0.497 -2.10 0.0386 0.557 -0.477
#> 9 1 9 0.892 -1.96 0.0548 0.565 0.276
#> 10 1 10 0.0587 -1.82 0.0753 0.573 -0.168
#> # … 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")