JuliaPlots / StatsPlots.jl

Statistical plotting recipes for Plots.jl
Other
440 stars 90 forks source link

Using `@df` with missing values #557

Open BeastyBlacksmith opened 2 months ago

BeastyBlacksmith commented 2 months ago

Trying to plot using the @df macro with missing data and I get broken lines.

g75bldn = DataFrame(:Day => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], :Patient => ["Patient A", "Patient A", "Patient A", "Patient A", "Patient A", "Patient A", "Patient A", "Patient A", "Patient A", "Patient A", "Patient A", "Patient A", "Patient B", "Patient B", "Patient B", "Patient B", "Patient B", "Patient B", "Patient B", "Patient B", "Patient B", "Patient B", "Patient B", "Patient B", "Patient C", "Patient C", "Patient C", "Patient C", "Patient C", "Patient C", "Patient C", "Patient C", "Patient C", "Patient C", "Patient C", "Patient C"], :BaselinedDoseNormalized => [3.382, 4.528, 1.37, 2.639, 0.937, 2.113, 1.741, 3.166, 3.568, missing, missing, 1.587, 2.585, 3.947, 6.331, 6.517, 7.446, 5.062, missing, missing, missing, missing, missing, 7.136, 0.596, 2.577, 23.073, 6.076, 2.361, 0.317, 3.847, 0.658, 3.042, 2.794, missing, missing])

@df g75bldn plot(:Day, :BaselinedDoseNormalized, group=:Patient, lw=1, msw=0, m=:circle, markersize=4, ls=:dash)

I get skipmissing ue)

If I try with skipmissing, I get

julia> @df skipmissing(g75bldn) [...]
ERROR: Only tables are supported

which I suppose is because it returns a Base.SkipMissing{DataFrame} type which StatsPlots doesn't like to injest. If I try

julia> @df g75bldn plot([...], skipmissing=true)

nothing changes, same as above, the line is still broken.

I know there are ways with for loops over columns and so on, but it completely defeats the purpose and ease of the @df macro, especially given how easy it automatically handles groups.