How to name a dataframe based on a value in a comprehension list

Hello, is there a way to name a dataframe using the value of x in a comprehension list? I hoped using $variable_I_am_interested would take the value of that variable and put it into the name, similar to using $ in a string.

I create one food web and run four different clearance scenarios on it and want to save their output. Here is an outline of how my functions look like:

function create_initial(species)
    bli
    bla
    return bloop
end

function clearance(bioS, clearance_V, species)
    saved_values = a() # not important
    callback() # not important
    results_test_$clearance_V = [saved_values.t hcat(saved_values.saveval...)']
    results_$clearance_V = DataFrame(results_test_$clearance_V)
    return results_$clearance_V
end

function one_foodweb()
    intial = create_initial(0)
    bioS = deepcopy(initial)
    one_foodweb_result = clearance(bioS,x,82) for x in 1:4] # I want the dataframe to take the name of this x
    return one_foodweb_result
end

all_foodweb_result = [one_foodweb() for x in 1:1]
# in the future I want to run this several times but I need a way of saving the output
# of each foodweb and clearance scenario

function initial(species)

There are a lot of possible hacks here (e.g. you could save all the DataFrames in a Dictionary, where you store the “name” you want to give them as a key), but to do this in a slightly more organized fashion you might want to look at DrWatson.jl

1 Like