Learn R Programming

set6 (version 0.1.1)

isSubset: Test If Two Sets Are Subsets

Description

Test If Two Sets Are Subsets

Usage

# S3 method for Set
<(x, y)

# S3 method for Set <=(x, y)

# S3 method for Set >(x, y)

# S3 method for Set >=(x, y)

Arguments

x, y

Value

If all is TRUE then returns TRUE if all x are subsets of the Set, otherwise FALSE. If all is FALSE then returns a vector of logicals corresponding to each individual element of x.

R6 Usage

$isSubset(x, proper = FALSE, all = FALSE)

Details

If using the method directly, and not via one of the operators then the additional boolean argument proper can be used to specify testing of subsets or proper subsets. A Set is a proper subset of another if it is fully contained by the other Set (i.e. not equal to) whereas a Set is a (non-proper) subset if it is fully contained by, or equal to, the other Set.

When calling isSubset on objects inheriting from Interval, the method treats the interval as if it is a Set, i.e. ordering and class are ignored. Use isSubinterval to test if one interval is a subinterval of another.

See Also

isSubinterval

Other set methods: contains, equals

Examples

Run this code
# NOT RUN {
Set$new(1,2,3)$isSubset(Set$new(1,2), proper = TRUE)
Set$new(1,2) < Set$new(1,2,3) # proper subset

c(Set$new(1,2,3), Set$new(1)) < Set$new(1,2,3) # not proper
Set$new(1,2,3) <= Set$new(1,2,3) # proper
# }

Run the code above in your browser using DataLab