as_pc: Display a probability as a (numeric and rounded) percentage.

View source: R/comp_util.R

as_pcR Documentation

Display a probability as a (numeric and rounded) percentage.

Description

as_pc is a function that displays a probability prob as a percentage (rounded to n_digits decimals).

Usage

as_pc(prob, n_digits = 2)

Arguments

prob

A probability (as a scalar or vector of numeric values from 0 to 1).

n_digits

Number of decimal places to which percentage is rounded. Default: n_digits = 2.

Details

as_pc and its complement function as_pb allow toggling the display of numeric values between percentages and probabilities.

Value

A percentage (as a numeric value).

See Also

is_prob verifies a probability; is_perc verifies a percentage; is_valid_prob_set verifies the validity of probability inputs; num contains basic numeric variables; init_num initializes basic numeric variables; prob contains current probability information; comp_prob computes current probability information; freq contains current frequency information; comp_freq computes current frequency information; comp_complement computes a probability's complement; comp_comp_pair computes pairs of complements.

Other utility functions: as_pb(), plot.box()

Other display functions: as_pb()

Examples

as_pc(.50)                # 50
as_pc(1/3)                # 33.33
as_pc(1/3, n_digits = 0)  # 33
as_pc(as_pb(12.3))        # 12.3


riskyr documentation built on Aug. 15, 2022, 9:09 a.m.