I can’t quite follow all of this, as I’m not familiar with the packages you are using, but this is almost certainly, as you suspected, not a good way to this. If I understand you correctly, you would like to make something like the following call:
typeof(default)(default; growth_rate = A[j,1], death_rate = A[j,2])
or something similar to it, but you have growth_rate and death_rate as strings. If you instead declare
sample_params = [:growth_rate, :death_rate]
you could inside your function do something like
#[...]
for col in eachcol(A)
nt = (; (sample_params[i] => col[i] for i in eachindex(col))...)
res = typeof(default)(default; nt...)
push!(samples, res)
end
#[...]
Here, nt is a NamedTuple, which can be splatted (using ...) into the keyword-argument slot of a function following a semicolon in the function call. If you need to use strings as inputs you can convert string to symbols using, e.g.,
sym_params = Symbol.(["growth_rate", "death_rate"])
I can’t check that the above works, but something along these lines should be better than what you’ve got.
Hopefully someone more familiar with the packages you’re using can come along and suggest an overall better design for your purposes.