strictOp {SoDA} | R Documentation |
The expression is checked for stricter conditions on compatible arguments; if the conditions fail an error or warning is issued. If no error is issued, the expression's value is returned.
withStrictOps(expr, attach = TRUE) strictOp(expr, warnOnly = FALSE, errorCall)
expr |
For withStrictOps , any expression to be evaluated. Subexpressions from the binary operators in the base package for arithmetic, comparison, and logic will be evaluated by stricter rules. For strictOp , the expression should only be one of these calls. Generally, withStrictOp will be more convenient to use, and strictOp is largely for internal use. |
attach |
Optional argument, only examined if expr is missing. If TRUE , then the "strictOps" environment is attached, overriding the applicable operators with strict versions. If attach is FALSE , this environment is detached. See the details. |
warnOnly |
If TRUE , only issue warnings on failures. |
errorCall |
Optional argument for internal use, supplying the expression to be used in error messages as the original call. |
The functions apply the stricter rules for compatibility given in section 7.1 of “Software for Data Analysis”.
Calling withStrictOps
evaluates an arbitrary expression with an environment containing strict versions of all the relevant operators.
Calling withStrictOps
with no arguments attaches this environment to the search list, overriding the base versions of the operators. If the expressions pass the strict rules, evaluation is passed on to the corresponding base package version of the operator.
the value of expr
sum(rnorm(3) == as.raw(1:3))# succeeds but comparison is ambiguous muststop(withStrictOps(sum(rnorm(3) == as.raw(1:3))), silent = FALSE) # signals an error