would work (did not test now).
So I have no “problem” in Base Julia, but to do it in Dataframes. Maybe it is trivial and I am blind…, but my naive
@combine df {outvar} = fun({vbl}...)
where vbl is a tuple of Symbols referring to columns.
I think for this you need to use {{ vbl }} because that’s meant to splice a tuple of column values into the expression which you can then splat with ....
but then the code @combine df {outvar} = fun({vbl}...) does not pass fun as parameter…
It seems to me that the minilanguage in DataFrames.jl already works the way you want: you can specifiy a variable number of columns and the function will be called with this number of parameters. Is the following not flexible enough?
using DataFrames
using Statistics
crazyRatio(x,y,z) = mean(x) / mean(y) / std(z)
# Just to show that all these things can be passed as parameters
fun = crazyRatio
vbl = [:x1, :x2, :x3]
outvar = :y
df = DataFrame(x1=rand(10), x2=rand(10), x3=rand(10))
combine(df, vbl => fun => outvar)
# Output
1Ă—1 DataFrame
Row │ y
│ Float64
─────┼─────────
1 │ 7.65015
Without testing it, I think it would work with @combine {string(fun)} = fun({{vbl}}...), so you splat the tuple resulting from {{vbl}} into fun. This is nice when you have to pass other parameters as well, for example fun(first_arg, {{vbl}}...) because then you cannot do vbl => fun in the minilanguage anymore, which is otherwise concise as well.
And I still think you don’t need to do @combine {string(fun)} = but just @combine string(fun) = ... because the {} was supposed to mean something else on the left side. But I have to check the implementation again why this even works…
That’s just because a tuple of symbols is not in the list of types I expect for column identifiers. Does names(df, (:x, :y, :z)) work? If it does, I should add it too, if not, I won’t