Closed idavydov closed 1 year ago
The problem is that the !!
is getting evaluated by mutate
instead of by partial()
. I think the easiest way to work around this is to just construct the function factory yourself:
library(tidyverse)
my_sqrt <- function(x) {
force(x)
function() sqrt(x)
}
tibble(x = 1:3) |>
rowwise() |>
mutate(square_root = list(my_sqrt(x)))
#> # A tibble: 3 × 2
#> # Rowwise:
#> x square_root
#> <int> <list>
#> 1 1 <fn>
#> 2 2 <fn>
#> 3 3 <fn>
Created on 2023-07-26 with reprex v2.0.2
I'm trying to create a list-column with functions. Each function should depend on arguments from that tibble row, so I'm using
purrr::partial()
.It seems that it's impossible to reproduce the
.lazy = FALSE
behavior with the!!
syntax.Created on 2023-04-20 with reprex v2.0.2
CC @klmr