setOperator
registers a user-defined operator as a given type.
Subsequently, this operator can be treated as a member of a class of
operators. setOperators
scans defined functions looking for any that
have been defined by the user using the special any
syntax.
If found, these are registered with setOperator
and given the
default type='user'.
setOperator( name, type="user" , ... )
setOperators( ... )
options('operators')
.setOperator
registers a single operator similar to the way
that setMethod
registers a method. The definition for these
operators are defined by .Options$operators
. setOperators
scans the environments for user-defined
operators. If found and not already registered, these are registered
by setOperator
. Registered operators are much more efficient
than unregisted ones, so it is often advantageous to register the
operators. When ...
is supplied, these attributes are set
for all unregistered operators.
Operators are allowed to have attributes. The one required
attribute is type
, which is just a character value that
serves to classification the operator. On package load, All operators
from base R are assigned a core type as specified in Syntax.
These are: namespace, component, indexing, sequence, arithmetic,
arithmetic, relational, logical, tilde, assignment, help.
Users may use one of these types or assign a type of their own
choosing. The type
is largely unrestricted, but cannot be
one of the reserved operator groupings: ALL, REG(ISTERED),
UNREG(ISTERED), SPECIAL or user. These have special meaning as
described in operators
. Users are encouraaged to
make their own types in lower case.
operators
, SyntaxsetOperator( ' operators( type='relational' )
Run the code above in your browser using DataLab