generate_AndOr {lazy.tools} | R Documentation |
Generation of character infix operators: '&', '&&', '|', '||'
generate_AndOr()
This function generates infix operators: '&', '&&', '|', '||'
in the global environment,
which are almost equivalent to, resp, '%&%', '%&&%', '%|%', '%||%' .
The difference is that '&' has precedence over '|' but '%&%' does NOT.
For example:
"a" | "b" & "c"
produces "(a) | ((b) & (c))"
but
"a" %|% "b" %&% "c"
produces "((a) | (b)) & (c)"
.
See the examples below.
"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)"
.
Use eval( parse(text=condition) )
to evaluate the expression.
To remove these operators:
rm( `&`, `&&`, `|`, `||` )
Generates four infix operators in the global environment.
generate_AndOr()
"a" & "b"
"a" %&% "b"
And( "a", "b" )
"a" | "b"
"a" %|% "b"
Or( "a", "b" )
# precedences
"a" | "b" & "c"
"a" %|% "b" %&% "c"
"a" & "b" | "c"
"a" %&% "b" %|% "c"