Hi,
I have a dataframe df with several columns, among which :P1, whose eltype is Union{Missing,Float64} and :Nome_Turma, whose eltype is String. I want to make a groupedhist, from StatsPlots.jl (or otherwise), but I get:
@df df groupedhist(:P1, group=:Nome_Turma)
ERROR: TypeError: non-boolean (Missing) used in boolean context
I know my column df.P1 does have missing values. Might this be the problem? If so, how should I correct it? Shouldn’t the command groupedhist do this automatically?
Yeah that won’t work because @df is a macro which can only see the actual code written, not any runtime values. This has nothing to do with the dropmissing, you just can’t write @df df groupedhist(etapa, group = :Nome_Turma) as the macro will expand this using the actual string etapa rather than the value of that variable.
That doesn’t change the fact that you want the macro to understand the runtime value of a variable, which just isn’t possible. Macros are just convenience to rewrite code, and the @df macro needs an actual Symbol in the written expression it transforms to work. See these two examples (where I’ve replaced your column names P1 with b and Nome_Turma with group):