ffp: Manipulate the 'ffp' Class

View source: R/ffp-vctrs.R

ffpR Documentation

Manipulate the ffp Class

Description

Helpers and Constructors from ffp.

Usage

ffp(x = double(), ...)

is_ffp(x)

as_ffp(x)

## Default S3 method:
as_ffp(x)

## S3 method for class 'integer'
as_ffp(x)

Arguments

x
  • For ffp(): A numeric vector.

  • For is_ffp(): An object to be tested.

  • For as_ffp(): An object to convert to ffp.

...

Additional attributes to be passed to ffp.

Details

The ffp class is designed to interact with doubles, but the output of c(ffp, double) or c(double, ffp) will always return a double (not an ffp object), since there is no way to guarantee the interaction between a numeric vector and a probability will also be a probability.

Value

  • ffp() and as_ffp() return an S3 vector of class ffp (built upon double's);

  • is_ffp() returns a logical object.

Examples

set.seed(123)
p <- runif(5)
p <- p / sum(p)

is_ffp(p)
as_ffp(p)

ffp documentation built on Sept. 29, 2022, 5:10 p.m.