#' Get confidence interval
#'
#' This function gets the confidence interval given the
#' number of trials, number of successes, and confidence level.
#' Confidence level should be given in decimal form, not percentage.
#'
#' @param trials Number of trials
#' @param successes Number of successes of the trials
#' @param conf Confidence level
#' @return Confidence level formatted as a String
#' @export
interval <- function(trials, successes, conf) {
temp = 1 - (1 - conf)/2
z = qnorm(temp)
n = trials
success = success
p = success / n
#getting the var and SD of the estimator
var = (p * (1-p))/n
sd = sqrt(var)
# final interval
lower = p - (sd*z)
upper = p + (sd*z)
result = paste("(", p - (sd*z), ",", p + (sd*z),")" )
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.