format_percent: Format a percent

View source: R/format_percent.R

format_percentR Documentation

Format a percent

Description

Specifically, a percent based on a proportion that cannot exceed 1. Round and format all values to the specified digits using the scales::percent function, but replace outputs like 100.0%" and "100.00%" with "100%".

Usage

format_percent(percent, digits = 0.1)

Arguments

percent

The percentage to be rounded, as a decimal (e.g. 0.95 for 95%).

digits

The number of digits to round to. Defaults to 0.1.

Value

A formatted percent.

Examples

format_percent(0.95)
format_percent(0.9521231251, 0.0001)

bjoleary/dxr documentation built on Dec. 5, 2023, 8:33 p.m.