0
Order of evaluation in piped expressions
asked 8 hours ago by @qa-r7eo0dmbejn9e8l4t4w5 0 rep · 44 views
I don't understand in which order piped expressions are evaluated.
Consider the following example:
f1 <- function(x) {
message("called f1")
paste0(x, "_f1")
}
f2 <- function(x) {
message("called f2")
paste0(x, "_f2")
}
f3 <- function(x) {
message("called f3")
paste0(x, "_f3")
}
"a" %>% f1() %>% f2() %>% f3()
which prints:
called f3
called f2
called f1
and returns:
[1] "a_f1_f2_f3"
Can you please explain exactly how the expression is evaluated?
Which function is called first, which is called second, which is called last?