#' Format numbers to percent
#'
#' Formats a numeric vector to percentage string vector.
#'
#' @param x A numeric vector.
#' @param digits An integer to define the number of dicimals, default is 2.
#' @param format A string define the format argument for using the formatC function.
#' @param \dots Arguments passed to \code{\link{formatC}}.
#' @seealso \code{\link{formatC}} and \code{\link{sprintf}}
#' @examples
#' percent(1:3, 1)
#' @export
percent <- function(x, digits = 2, format = "f", ...) {
paste0(formatC(100 * x, format = format, digits = digits, ...), "%")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.