Hi,
I have a problem with Interact, where I don’t understand what is wrong. I have the following MWE.
I have a csv file with several columns that might look like this:
Result,A_Result,B_Result,C_Result
10,1,3,4
12,3,4,5
12,3,7,8
23,5,7,8
23,4,6,8
I want to plot the results and use interact to switch between the columns.
using CSV
using Interact
csvdata = CSV.File("test.csv")
parts = [:all,:A,:B,:C]
ui = @manipulate for part in parts
if part == :all
result = csvdata.Result
else
println(part)
@eval result = csvdata.$(Symbol("$(part)",'_',"Result"))
end
p1 = plot(result)
end
The :all column works fine, but for the other columns it doesn’t and I get an error (UndefVarError: result not defined)
.
The issue appears both in IJulia notebook and when I use Blink.
If I remove the if-else block and do it like this:
using CSV
using Interact
csvdata = CSV.File("test.csv")
parts = [:A,:B,:C]
ui = @manipulate for part in parts
@eval result = csvdata.$(Symbol("$(part)",'_',"Result"))
p1 = plot(result)
end
It works as expected.
Am I missing anything?
I am using julia 1.5.3
hagi