For whatever reason I was playing with magrittr
pipe syntax, and came across a weird error that occurs when you scope explicitly qualify the call to %>%
. I know that using the syntax below destroys the purpose of the pipe, but I'm curious as to why the error occurs.
The first call to sum
works as expected and outputs a 1
.
The second call causes the error: Error in pipes[[i]] : subscript out of bounds
.
library(magrittr)
`%>%`(1,sum())
magrittr::`%>%`(1,sum())
Looking at the pipe's source code I'm thinking the cause for the error is related to the first lines manipulating the environment, but I'm sure as to what problem it's introducing.
function (lhs, rhs) {
parent <- parent.frame()
env <- new.env(parent = parent)
chain_parts <- split_chain(match.call(), env = env)
Can anyone explain this behavior?