Package 'ptvalue'

Title: Working with Precision Teaching Values
Description: An implementation of an S3 class based on a double vector for storing and displaying precision teaching measures, representing a growing or a decaying (multiplicative) change between two frequencies. The main format method allows researchers to display measures (including data.frame) that respect the established conventions in the precision teaching community (i.e., prefixed multiplication or division symbol, displayed number <= 1). Basic multiplication and division methods are allowed and other useful functions are provided for creating, converting or inverting precision teaching measures. For more details, see Pennypacker, Gutierrez and Lindsley (2003, ISBN: 1-881317-13-7).
Authors: Alexandre Gellen-Kamel [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-0382-2478>)
Maintainer: Alexandre Gellen-Kamel <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0.9000
Built: 2026-05-29 10:25:15 UTC
Source: https://github.com/agkamel/ptvalue

Help Index


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 1x\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: Working with precision teaching values

Description

This class allow to print precision teaching measures with the times or the division symbols (ex. ×2\times 2, ÷1.4\div 1.4) by converting numeric values to precision teaching values. More specifically, providing:

  • Values between ]0,1[] 0, 1 [ will return output values 1\geq 1 with a prefixed div (÷\div) symbol (ex. ).

  • Values between [1,[[ 1, \infty [ will return output values 1\geq 1 with a prefixed times (×\times) symbol.

  • Values of 00 will return ÷\divInf.

  • Inf values will return ×\timesInf.

  • NA values will return NA.

Usage

ptvalue(x = double())

is_ptvalue(x)

as_ptvalue(x, ...)

## Default S3 method:
as_ptvalue(x, ...)

Arguments

x

A numeric vector. Values must be 0\geq 0.

...

Other values passed to method.

Value

A numeric vector of class ptvalue that represents precision teaching measures.

See Also

times(), div()

Examples

# Basic examples
x <- c(0.5, 0.8, 1, 1.25, 2)
ptvalue(x)

ptvalue(0)
ptvalue(NA)
ptvalue(Inf)

# For convenience, `div()` can be used to
# create decaying values without using decimal values
ptvalue(c(0.5, 0.8))
div(c(2, 1.25))

x <- ptvalue(2)
is_ptvalue(x)

x <- 2
is_ptvalue(x)

x <- c(0.5, 1, 2)
as_ptvalue(x)

Create times or div vector of class ptvalue

Description

times() and div() are convenient and stricter functions for creating growing or decaying precision teaching values with numeric values greater or equal than 1 (or otherwise raise an error).

Usage

times(x = double())

div(x = double())

Arguments

x

A numeric vector. Values must be greater or equal than 1.

Details

Note that providing a vector of class ptvalue to times() or div() will raise an error as these functions are stricter.

Value

A numeric vector of class ptvalue that represent precision teaching measures.

Examples

x <- c(1, 2, 4)
times(x)
div(x)

# `div()` can be useful for specifying div values without
#   the need to convert them first into values under zero
ptvalue(c(0.25, 0.5, 1, 2, 4))
ptvalue(c(div(4), div(2), 1, 2, 4))