is_freq: Verify that input is a frequency (positive integer value).

View source: R/comp_util.R

is_freqR Documentation

Verify that input is a frequency (positive integer value).

Description

is_freq is a function that checks whether its single argument freq is a frequency (i.e., a positive numeric integer value).

Usage

is_freq(freq)

Arguments

freq

A single (typically numeric) argument.

Value

A Boolean value: TRUE if freq is a frequency (positive integer), otherwise FALSE.

See Also

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; is_valid_prob_set verifies the validity of probability inputs; as_pc displays a probability as a percentage; as_pb displays a percentage as probability.

Other verification functions: is_complement(), is_extreme_prob_set(), is_integer(), is_matrix(), is_perc(), is_prob(), is_suff_prob_set(), is_valid_prob_pair(), is_valid_prob_set(), is_valid_prob_triple()

Examples

# ways to succeed:
is_freq(2)    # => TRUE, but does NOT return the frequency 2.
is_freq(0:3)  # => TRUE (for vector)

## ways to fail:
# is_freq(-1)            # => FALSE + warning (negative values)
# is_freq(1:-1)          # => FALSE (for vector) + warning (negative values)
# is_freq(c(1, 1.5, 2))  # => FALSE (for vector) + warning (non-integer values)

## note:
# is.integer(2)          # => FALSE!


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