%>>% | R Documentation |
The not-a-pipe operator that tracks changes in data.
lhs %>>% rhs
lhs %L>% rhs
lhs |
Input value |
rhs |
Function call or 'dotted' expression (see below). as value |
The operators %L>%
and %>>%
are synonyms. The %L>%
is the default since version 0.3.0 to avoid confusion with the %>>%
operator of the pipeR
package but %>>%
still works.
The lumberjack operator behaves as a simplified version of the
magrittr
pipe operator. The basic behavior of lhs %>>% rhs
is
the following:
If the rhs
uses dot-variables (.
), these are interpreted
as the left-hand side, except in formulas where dots already have a special
meaning.
If the rhs
is a function call, with no dot-variables used, the
lhs
is used as its first argument.
The most notable differences with 'magrittr' are the following.
it does not allow you to define functions in the magrittr style,
like a <- . %>% sin(.)
there is no assignment-pipe like %<>%
.
you cannot do things like x %>% sin
(without the brackets).
If the left-hand-side is tagged for logging, the lumberjack will update the
log by calling the logger's $add()
method, with arguments meta
,
input
, output
. Here, meta
is a list with information on
the operations performed, and input and output are the left-hand-side and the
result, respectively.
Other control:
dump_log()
,
get_log()
,
run_file()
,
start_log()
,
stop_log()
# pass arguments to a function
1:3 %L>% mean()
# pass arguments using "."
TRUE %L>% mean(c(1,NA,3), na.rm = .)
# pass arguments to an expression, using "."
1:3 %L>% { 3 * .}
# in a more complicated expression, return "." explicitly
women %L>% { .$height <- 2*.$height; . }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.