comp: Bounded types for properties

Description Usage Arguments Details Author(s) Examples

Description

This set of classes define different numerical object with restriction on it.

Usage

1

Arguments

object

object to be coerced

Details

These special classes could be registered as signaling fields by calling signalingFields or signalingField, or using setProperties, so they could be used for GUI design, and changing of the fields automatically validate the current value

The construction of these objects has validation with them, please see the example.

PositiveInteger(object)

Construct a PositiveInteger object

NonpositiveInteger(object)

Construct a NonpositiveInteger object

NegativeInteger(object)

Construct a NegativeInteger object

NonnegativeInteger(object)

Construct a NonnegativeInteger object

Author(s)

Tengfei Yin, Michael Lawrence

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Constructors
require(objectProperties)
obj <- PositiveInteger(1)
obj <- NonnegativeInteger(0)
obj <- NegativeInteger(-1)
obj <- NonpositiveInteger(0)
## setting as properties
filt.gen <- setRefClass("Filter",
properties(list(cutoff = "NonnegativeInteger",
weight = "PositiveInteger")), contains = "PropertySet")
## new property instance
obj <- filt.gen$new(cutoff = 0, weight = 1)
obj$properties()
as.list(obj)
## get the value
obj$cutoff
## set the value
obj$cutoff <- 30
## the class doesn't change
## if you pass a value which out of boundary, it will throw an error message
obj$cutoff
class(obj$cutoff)

ggobi/objectProperties documentation built on July 20, 2021, 2:21 p.m.