Hi,
I started by creating a tidyeval function that I can use to do least-squares fitting and apply business rules. I wanted it to be generic, so I specify which columns are the data data inputs for the model. It returns a tibble with the parameters of the fitted model:
fitPL <- function(data, conc, signal) {
conc <- enquo(conc)
signal <- enquo(signal)
#
# calculations here using !!conc and !!signal
# ...
#
return(ti.res)
}
This now works perfectly well if I call it using do(), given that Condition, Concentration and Result are columns of ti.data:
ti.fits <- ti.data %>%
group_by(Condition) %>%
do(fitPL(., Concentration, Result))
However, the fitPL() is fairly slow! And the problem is embarrassingly parallelizable, so I would like to call it as, say:
ti.fits <- ti.data %>%
split(.$Condition) %>%
future_map_dfr(.f = fitPL, conc = Concentration, signal = Result)
This of course gives an error because 'Concentration' does not exist to the future_map_dfr() call. But it also gives an error if I pass the column name as a character value, because then fitPL tries to do its calculations using the character value as its (only) input.
Do I need to wrap the column parameters some way? Or do I need to rewrite fitPL so that it also (?) accepts character inputs? Can I have it both ways (i.e. passing these parameters with or without quotes)?