paste_pct_sum {DIZtools}R Documentation

Get the percentage of two values pretty formatted.

Description

Get the percentage of two values pretty formatted. Thanks to kapsner for the inspiration!

Usage

paste_pct_sum(
  x,
  pct_ref = 1,
  with_percent_sign = TRUE,
  with_absolute = TRUE,
  decimal_separator = ".",
  digits = 2
)

Arguments

x

(numeric) The absolute value.

pct_ref

(numeric, Optional) The reference value to which the ratio of the absolute value x is calculated. Default is 1.

with_percent_sign

(boolean, Optional) Should a percentage sign be added to the final string? Default = TRUE

with_absolute

(boolean, Optional) Should the two absolute reference values also be output? Default = TRUE

decimal_separator

(string, optional) The character to be used to indicate the numeric decimal point.

digits

(int, optional) The number of digits after the decimal separator to round to.

Value

A character string.

Examples

  paste_pct_sum(.15, 2)
  #> "7.50% (0.15 of 2)"

[Package DIZtools version 1.0.1 Index]