andor {lazy.andor} | R Documentation |
Generation of string infix operators
andor(A, B) "&"(A, B = NULL) "|"(A, B = NULL) "&&"(A, B = NULL) "||"(A, B = NULL)
A |
The first argument |
B |
The second argument |
This package generates infix operators: '&', '&&', '|', '||',
which are almost equivalent to, resp, '%&%', '%&&%', '%|%', '%||%'
in the package lazy.tools.
The difference is that '&' has precedence over '|“ but '%&%“ does NOT.
Therefore, it is better to use parentheses.
See the descriptions of And, Or, and Not in the package lazy.tools.
"a" & "b"
is equivalent to And( "a", "b" )
and generates "(a) & (b)"
.
"a" && "b"
is equivalent to And( "a", "b", oper="&&" )
and generates "(a) && (b)"
.
"a" | "b"
is equivalent to Or( "a", "b" )
and generates "(a) | (b)"
.
"a" || "b"
is equivalent to Or( "a", "b", oper="||" )
and generates "(a) || (b)"
.
Note that '&' has precedence over '|“ but '%&%“ does NOT.
Use eval( parse(text=condition) )
to evaluate the expression.
To remove these operators:
detach("package:lazy.andor", unload=TRUE)
a string
"a" & "b" And( "a", "b" ) "a" | "b" Or( "a", "b" ) "a" | "b" & "c" "a" %|% "b" %&% "c" "a" & "b" | "c" "a" %&% "b" %|% "c"