Created
April 22, 2020 13:35
-
-
Save aviatesk/addac4484f8f455f4bf5ad14ef137eb0 to your computer and use it in GitHub Desktop.
plotting `@linq` chain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DataFrames, DataFramesMeta, Plots, StatsPlots, StatsBase | |
# HACK: | |
# integrate StatsPlots.@df into @linq chain in a way data frame keeps to be passed even after plot | |
# but, the `names` part might be too dangerous | |
for n in names(StatsPlots) | |
function DataFramesMeta.linq(::DataFramesMeta.SymbolParameter{n}, d, args...) | |
plotcall = Expr(:call, n, args...) | |
return quote let d = $d | |
display(@df d $plotcall) | |
d | |
end end | |
end | |
end | |
@linq DataFrame(name = rand('A':'Z', 1000), val = rand(1000)) |> | |
by(:name, mean = mean(:val)) |> | |
sort(:name) |> | |
bar(:name, :mean; orientation = :horizontal) |> | |
transform(meanall = fill(mean(:mean), length(:mean))) |> | |
vline!(:meanall) |
Author
aviatesk
commented
Apr 22, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment