Might be related to #1491 and hybrid evaluation, but this a different issue.
This is a little involved (it took me quite a while to figure out the REPEX), so hang on:
When we assign a list object in a mutate call after a rowwise it seems that the values which depends on other columns are reassigned after all calls have been done to the last value of the column variable. It's one of the extremely weird bugs that only our dear R can produce.
The best real-world example would be fitting models with different parameters, but I cooked you a small repex:
ft <- function(test) {
res <- list(tt = test, tt2 = !!test)
test2 <- test
res$tt3 <- test2
return(res)
}
data.frame(prob = c(F,F,F,T)) %>% tbl_df %>% rowwise() %>%
mutate(model = list(ft(prob)),
probFromModel = model[["tt"]],
probAssignedFromModel = model[["tt3"]],
probComputedFromModel = model[["tt2"]])
# Source: local data frame [4 x 5]
# Groups: <by row>
#
# prob model probFromModel probAssignedFromModel probComputedFromModel
# (lgl) (chr) (lgl) (lgl) (lgl)
#1 FALSE <list[3]> TRUE TRUE FALSE
#2 FALSE <list[3]> TRUE TRUE FALSE
#3 FALSE <list[3]> TRUE TRUE FALSE
#4 TRUE <list[3]> TRUE TRUE TRUE
We can see that (i) the "test" value is right when it is evaluated, (ii) computed values (copied) are okay (iii) any value that are "shallowed" copied (even the re-assignment) are prone to the bug.
The function is here to test re-assignment, but doing something like model = list(list(tt=...)) works the same.
Seems like a bug around hybrid evaluation and the fact that we might want to enforce some kind of deep-copy of the arguments.