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

**URL:** <https://discourse.julialang.org/t/how-to-name-a-dataframe-based-on-a-value-in-a-comprehension-list/40655>\
**Category:** General Usage\
**Created:** [June 3, 2020, 9:15am UTC](https://discourse.julialang.org/t/how-to-name-a-dataframe-based-on-a-value-in-a-comprehension-list/40655 "2020-06-03T09:15:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HelgavonLichtenstein](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgavonlichtenstein/32/5005_2.png) [@HelgavonLichtenstein](https://discourse.julialang.org/u/HelgavonLichtenstein)\
**Post date:** [June 3, 2020, 9:15am UTC](https://discourse.julialang.org/t/how-to-name-a-dataframe-based-on-a-value-in-a-comprehension-list/40655/1 "2020-06-03T09:15:33Z")

</div>

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:

```julia
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)

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [June 3, 2020, 9:24am UTC](https://discourse.julialang.org/t/how-to-name-a-dataframe-based-on-a-value-in-a-comprehension-list/40655/2 "2020-06-03T09:24:33Z")

</div>

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](https://github.com/JuliaDynamics/DrWatson.jl)
