class_schema_setops: Schema: set operations for schemas

Description Usage Arguments Details Value See Also

Description

Similar to base R set functions, but for objects of class Schema. Functions sintersect(), sdiff() and sequal() compare any R object that has a defined as_schema() method to an object of class Schema.

Usage

1
2
3
4
5
sintersect(x, y, what = c("inputs", "types"))

sdiff(x, y, what = c("inputs", "types"))

sequal(x, y, what = c("inputs", "types", "strict"))

Arguments

x

an object of class Schema or any other R object that has a defined as_schema() method.

y

an object of class Schema.

what

a character equal to:

  • "inputs" (match inputs only),

  • "types" (match prototypes' classes of common inputs) or

  • "strict" (for sequal() only, match everything).

Argument what is matched partially and can be abbreviated

Details

These functions compare the structure of x to what y dictates. Comparisons are always done with respect to y:

Function sequal() is a wrapper to sdiff(). A "strict" comparison checks both inputs and prototypes. If the intersection of y and x is y, then x and y are considered to be equal schemas.

Method dispatch

If x is not an object of class Schema, it it coerced to such an object by using the appropriate as_schema() method. This is why set functions are not generic functions, method dispath is implicitely done by as_schema().

Comparing prototypes

Comparing prototypes makes sense only for common inputs to y and x. Consequently, comparing prototypes triggers a comparison between inputs first.

Value

Functions sintersect() and sdiff() return a named character, possibly empty. The output of sintersect() is the set of common inputs (in the sense given by what) to y and x, while the output of sdiff() is the set of inputs that are in y but not in x.

Function sequal() returns a logical. A TRUE implies equality in the sense given by what.

See Also

Other Schema: Schema-accessors, Schema-class, Schema-coercions, Schema-extractors, Schema-methods, Schema-validators, is_schema()


jeanmathieupotvin/cargo documentation built on Oct. 27, 2020, 5:22 p.m.