This code works produces a nice chart:
using DataFrames, StatsPlots df = DataFrame(A = rand(20), C = repeat([1,2,3, 4], inner = 5)) plt_dens1 = @df df density( :A, group = :C, title = "This works" )
If the Symbol arguments are constructed as below, code that is similar does not work. It generates an error message starting with:
"ERROR: MethodError: no method matching _extract_group_attributes(::Symbol, ::Symbol)" is generated."
asymb = Symbol("A") csymb = Symbol("C") plt_dens2 = @df df density( asymb, group = csymb, title = "This doesn't work" )
Question: Does this mean Julia does not respect referential transparency?
Fortunately this code generates a chart just like the first one:
plt_dens3 = @df df density( df[:, Symbol("A")], group = df[:, Symbol("C")], title = "This also works" )
However, it is a little more cumbersome.
Question: Why doesn’t the code for plt_dens2 work and is there a simple way to fix the problem?