results, xi, xj = ([] for count in 1:6)
for comb in c
i, j = comb #assign the rows of comb[i] to i and comb[j] to j
result = algae(xi = df1[:, i], xj = df2[:, j], y = tool)
append!(xi, i)
append!(xj, j)
append!(results, result)
end
Here c is a combinations range, algae is an external function which is measuring the values and df1, df2, y are dataframes which are used as inputs.
The first issue is that the xi, xj is not taking in values from df1 and df2 .
Secondly, I want to append or store the values for each iteration in an empty array (previously
initialized) but it does not perform this operation.
My objective is to be able to print the an array showing xi, xj and result.
Please suggest a solution for this problem.
Thanks in advance.
Please ensure that you link questions if cross-posting on multiple sites - this was asked originally on StackOverflow here.
As I said in the SO comment, it’s hard to help without a minimum working example, please read this thread for further help.
Here’s a minimum example that addresses your second point (slightly elongated from what I posted in my SO comment as there’s no character limit here!):
julia> xi, xj = ([] for _ ∈ 1:2)
Base.Generator{UnitRange{Int64}, var"#1#2"}(var"#1#2"(), 1:2)
julia> for c ∈ zip(1:5, 6:10)
i, j = c
append!(xi, i)
append!(xj, j)
end
julia> xi
5-element Vector{Any}:
1
2
3
4
5
julia> xj
5-element Vector{Any}:
6
7
8
9
10
This is why a minimum working example is useful - your code does not show what c actually is (what is a “combinations range”?), nor does it show what the output of your loop is and how it’s different from what you expected (i.e. in what sense did the code “not perform this operation”).
I also don’t see anything wrong with your call to algae on the face of it, and it’s not clear to me what “xi, xj is not taking in values from df1 and df2” actually means - again it would be helpful if your code actually demonstrated your issue in a reproducible manner.