R/formatPercent.R

Defines functions formatPercent

Documented in formatPercent

#' Format a Numeric Proportion
#' 
#' Takes a number and formats it as a percentage.  Used by
#' \code{\link{confIntIndependentProportion}}.
#' 
#' 
#' @param x numeric vector of proportions
#' @param digits number of digits
#' @author Leonhard Held
#' @examples
#' 
#' formatPercent(c(0.115, 0.5))  # "11.5%" "50.0%"
#' 
#' @export
formatPercent <- function(x, digits = 1){
  paste(formatC(x * 100, digits = digits, format = "f"), "%", sep = "")
}
felix-hof/biostatUZH documentation built on Sept. 27, 2024, 1:48 p.m.