You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just ran into this problem and made a reprex to figure it out. Wouldn't take much to turn it into a quick blog post about the value of purrr::partial().
library(purrr)
library(tidyr)
library(dplyr)
# NA-ify some populationspopulation[sample(seq_len(nrow(population)), 100), "population"] <-NA
This is a simple function abstracting a data processing pipe but where we want to pass the ... to a function used inside an anonymous function.
The ... are not what we think they are inside an anonymous function. If we create a partial function and pass the dots first, outside of the anonymous function, they get where they need to go.
Finally, this might also work because the dots aren’t inside an anonymous function, but it’s a little confusing or could be difficult to set up in more complicated situations.
Just ran into this problem and made a reprex to figure it out. Wouldn't take much to turn it into a quick blog post about the value of
purrr::partial()
.This is a simple function abstracting a data processing pipe but where we want to pass the
...
to a function used inside an anonymous function.This doesn’t work and it gives you a completely bonkers error message. Who said anything about
trim
?But you're convinced this should work because if you put
na.rm
in the pipe chain directly it works.The
...
are not what we think they are inside an anonymous function. If we create a partial function and pass the dots first, outside of the anonymous function, they get where they need to go.Finally, this might also work because the dots aren’t inside an anonymous function, but it’s a little confusing or could be difficult to set up in more complicated situations.
The text was updated successfully, but these errors were encountered: