From a0770998d0bc062e18de572738b5b8357f2db147 Mon Sep 17 00:00:00 2001 From: piever Date: Thu, 18 Jan 2018 14:14:29 +0000 Subject: [PATCH] group by more than one column --- README.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8d40a7db9..fe9d09ec8 100644 --- a/README.md +++ b/README.md @@ -64,10 +64,26 @@ df |> @df scatter(:b, :d) ``` -The old syntax, passing the `DataFrame` as the first argument to the `plot` call is still supported, but has several limitations (the most important being incompatibility with user recipes): +The `@df` syntax is also compatible with Plots grouping machinery: + +```julia +using RDatasets +school = RDatasets.dataset("mlmRev","Hsb82") +@df school density(:MAch, group = :Sx) +``` + +To group by more than one column, use a tuple of symbols: + ```julia -plot(df, :a, [:b :c], colour = [:red :blue]) +@df school density(:MAch, group = (:Sx, :Sector), legend = :topleft) ``` + +![grouped](https://user-images.githubusercontent.com/6333339/35101563-eacf9be4-fc57-11e7-88d3-db5bb47b08ac.png) + +--- + +The old syntax, passing the `DataFrame` as the first argument to the `plot` call is no longer supported. + --- ## marginalhist with DataFrames