integerSet: An S4 class to represent a set of integers

View source: R/B001_integerSet.R

integerSetR Documentation

An S4 class to represent a set of integers

Description

An S4 class to describe a set of integers using conditions. Here are some examples;

  • Any integer from 5 to 10 or from 50 to 100

  • Any integer under 7

  • Any integer in the vector c(12,11,17,14)

It can also represent the union of such sets. For example any integer that meets any one of the above conditions.

The function integerCheck checks whether a given integer belongs to a given integerSet.

Usage

integerSet(...)

## S4 method for signature 'integerSet'
initialize(
  .Object,
  integers = numeric(),
  from = numeric(),
  to = numeric(),
  over = numeric(),
  under = numeric()
)

integerSet(...)

frames(...)

integerCheck(inputNum, inputSet)

Arguments

integers, from, to, over, under

parameters for the constructor new("integerSet") go directly into the relevant slots

inputNum

a single to number to be compared against inputSet

inputSet

an integerSet object

Details

integerCheck(number,set) will return TRUE if

  • number belongs to set@integers

  • number>set@over

  • number<set@under

  • sum(number>set@from)>sum(number>set@to)

If none of these conditions are met, integerCheck will return FALSE. The only exception to all of this is if set@integers contains -Inf. In this case, integerCheck will always FALSE.

Slots

integers

A vector of integers.

from

stuff

to

see from

over

lala

under

Like over, but for the < operator

Examples

#An integer set
autoPass=new("integerSet")
integerCheck(4,autoPass)  
autoFail=new("integerSet",integers=-Inf)
integerCheck(4,autoFail)

R-graphic-design/RGD documentation built on Jan. 2, 2023, 10:30 p.m.