Based on a master’s solution here, I have adapted the code to handle it:
using DataFrames
function calc(x1,x2, suffix)
y1 = accumulate(+, x1+x2 .+ 0.1rand())
y2 = accumulate(*, y1)
y3 = accumulate(+, y2 ./ x1)
mynames = Symbol.((:y1, :y2, :y3), "_$suffix")
return (;zip(mynames, (y1,y2,y3))...)
end
d = DataFrame(x1=rand(100), x2=rand(100))
hcat(d, DataFrame(calc(d.x1, d.x2, "mycalc")))