convert_sign: Basic functions for converting ptvalues

invert_signR Documentation

Basic functions for converting ptvalues

Description

  • invert_sign() inverts ptvalues' sign.

  • abs_sign() converts ptvalues' sign to an 'absolute' sign, times or div.

  • as_times() converts ptvalues' sign to all times.

  • as_div() converts ptvalues' sign to all div.

Usage

invert_sign(x = double())

abs_sign(x = double(), sign = "times")

as_times(x = double())

as_div(x = double())

Arguments

x

A vector of class ptvalue or a numeric vector. If a numeric vector is provided, values must be greater than 0.

sign

Either "times" or "div". Default to "times".

Details

The function invert_sign() is the same as applying \frac{1}{x} with the underlying numeric values of ptvalues. Times values (\times) will be converted to div (\div) and div to times.

The function abs_sign() finds the multiplicative absolute values where all times and div values are converted to times values (by default). It can also converts to all div values by specifying sign = "div".

Functions as_times() and as_div() are wrappers of abs_sign() where sign = "times" is specified for as_times() and sign = "div" is specified for as_div().

All functions will return a vector of class ptvalue even when providing a numeric vector for x as it is the expected use. To see the underlying numeric vector, you can use unclass() or as.double().

Value

A vector of class ptvalue.

Examples

x <- ptvalue(c(0.25, 0.5, 1, 2, 4))
x

abs_sign(x)
invert_sign(x)
as_times(x)
as_div(x)

ptvalue documentation built on Nov. 5, 2025, 7:14 p.m.