Description Usage Arguments dubious operators dubious pipes dubious syntaxes Examples
?
was modified to allow definition of new operators (unary, binary or n-ary).
We refer to those as "dubious" operators, both as a reference to the
package name and to emphasize the fact that they're not parsed as proper
operators.
.
Standard usage as documented in ?utils::Question
still works.
1 | `?`(e1, e2)
|
e1 |
lhs |
e2 |
rhs |
Every accessible function, custom defined or base/packaged, can be called as
an infix operator, for example 1:5 %%intersect? 3:7
is equivalent to
intersect(1:5, 3:7)
. In that case, %%intersect?
will have the precedence
of %%
, which is the most intuitive,
but any precedence including and below unary +
can be used, for instance
*intersect?
will have the precedence of *
.
Unary operators can be used to, for instance ~head? x
is the same as
head(x)
. This form can also be used with several arguments, but in this
case we need to write ~head? {x ; n)
for instance, which is convenient to go
to the next line without the need of a comma.
We can pipe with a chosen precedence by using a dubious pipe, for instance
x + y ~saveRDS? file
will save x + y
, not just x
We can pipe with a chosen precedence by using a dubious pipe, for instance
x + y ~saveRDS? file
will save x + y
, not just x
defining "?add: ({x})({y})" <- "{x} + {y}"
will allow us to call
?add: (a)(b)
to add a
and b
.
1 2 3 4 5 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.