First, thank you for an incredibly useful package. I'm a big fan of magrittr and appreciative of the work that you do. This is the first time I've run into unexpected behavior, so here goes.
an edit: it seems like |> gets me the result I expected; so this is probably more appropriately addressed on stackoverflow. apologies!
I was hoping to call set_attr and pass it the result of sys.function. This doesn't work / no attribute is set. I'm using magrittr version 2.0.3.
library(magrittr)
f <- function() {
"hello" %>%
magrittr::set_attr("g", sys.function())
}
r <- f()
#' this fails as attr(r, "g") returns NULL
testthat::expect_true(
is.function(attr(r, "g"))
)
Experimenting, I found that I could get the expected result using attr<- in lieu of set_attr. Also, assigning to an intermediate variable, phi, in the execution environment, i.e., phi <- sys.function(), before calling set_attr with phi worked. This made me wonder if the issue might be related to #195. It's also possible (likely) that I have the wrong expectations. Please don't hesitate to point me back to any relevant documentation, and thanks for any clarity you can provide.
First, thank you for an incredibly useful package. I'm a big fan of
magrittr
and appreciative of the work that you do. This is the first time I've run into unexpected behavior, so here goes.I was hoping to call
set_attr
and pass it the result ofsys.function
. This doesn't work / no attribute is set. I'm using magrittr version 2.0.3.Experimenting, I found that I could get the expected result using
attr<-
in lieu ofset_attr
. Also, assigning to an intermediate variable,phi
, in the execution environment, i.e.,phi <- sys.function()
, before callingset_attr
withphi
worked. This made me wonder if the issue might be related to #195. It's also possible (likely) that I have the wrong expectations. Please don't hesitate to point me back to any relevant documentation, and thanks for any clarity you can provide.