Created
June 13, 2017 17:28
-
-
Save christophergandrud/0494d30ae2afaa580c3be42d5af9c044 to your computer and use it in GitHub Desktop.
Simple function for simulating/plotting beta distributions for Dataverse 2017 Package Development Workshop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' @import ggplot2 | |
#' @export | |
beta_plot <- function(n = 10000, a = 1, b = 3) { | |
# draw distributions | |
sims <- rbeta(n = n, shape1 = a, shape2 = b) | |
# convert to data frame for ggplot2 compatability | |
sims <- data.frame(x = sims) | |
# plot probability density function | |
ggplot(sims, aes(x)) + | |
geom_density() + | |
xlab("") + ylab("Probability Density Function") + | |
theme_bw() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment