Skip to content

Instantly share code, notes, and snippets.

View jongbinjung's full-sized avatar

Jongbin Jung jongbinjung

View GitHub Profile
@jongbinjung
jongbinjung / gist:8eaef8cb335392aba63d
Created September 30, 2015 18:10 — forked from jrnold/gist:6799152
Create a plot of the normal distribution with an area shaded in. Useful for teaching z-scores and stuff like that.
library("ggplot2")
#' Draw Normal Distribution Density with an area shaded in.
#'
#' @param lb Lower bound of the shaded area. Use \code{-Inf} for a left tail.
#' @param ub Upper bound of the shaded area. Use \code{Inf} for a right tail.
#' @param mean Mean of the normal distribution
#' @param sd Standard deviation of the normal distribution
#' @param limits Lower and upper bounds on the x-axis of the area displayed.
#' @return ggplot object.