Using a (computed) function in DataFrames with multiple arguments

Thanks! You are right on both points! I thought I had tried {{vbl}}..., and it did not work . But I does work.

So this is, what I initially intended:

function calc_df(df, vbl, gr, fun)

   @chain df begin
   @groupby {gr}
   @combine string(fun)= fun({{vbl}}...)
   #end     
end

crazyRatio(x,y,z) = mean(x) / mean(y) / std(z)

 df = DataFrame(x1=rand(20), x2=rand(20), x3=rand(20), grp = repeat('A':'D'; inner=5))
 calc_df(df, [:x1, :x2, :x3], :grp, crazyRatio)

Ah, now I remember why it did not work: passing a Tuple of symbols did not work, i.e.

 calc_df(df, (:x1, :x2, :x3), :grp, crazyRatio)

I am still lacking the needed intuition I guess…