Function like expand.grid in R

I think the simplest is to iterate the Iterators.product, which gives Tuples (that is, it loses name information). Then you can convert on the fly to named tuples, and pass the resulting iterator to DataFrame. For example

function expand_grid(; kws...)
    names, vals = keys(kws), values(kws)
    return DataFrame(NamedTuple{names}(t) for t in Iterators.product(vals...))
end
5 Likes