R/as_percent.R

Defines functions as_percent

Documented in as_percent

#' Convert as percent (string)
#' 
#' Convert a numeric value into a string with percentage sign.
#' @param num Numeric vector to pass through
#' @param rounding Number of decimal places to round to. Default is 0.
#' @examples 
#' as_percent(.86748)
#' @export
as_percent <- function(num, rounding = 0){
  paste0(round(num * 100, rounding),"%")
}
martinctc/surveytoolbox documentation built on Feb. 20, 2025, 8:33 p.m.