sns_bar
sns_bar(df, groupcol, valuecol, [agg])
Input: df, groupcol, valuecol, agg · Output: no output
What it is
Aggregates column valuecol (string, column name) within each distinct value of groupcol (string, column name) of Table df, using aggregator agg (string, positional, default "mean"; also accepts things like "sum"/"median" depending on what the underlying aggregation supports), and plots the one resulting number per group as bars.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
sns_bar(df, groupcol, valuecol, [agg]) | df string or Tablenot documented yetgroupcol string or Tablenot documented yetvaluecol string or Tablenot documented yetagg string or Table, optionalnot documented yet | no output | — |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
df = table(x = randn(30, seed = 1), y = randn(30, seed = 2),
grp = ["a","b","a","b","a","b","a","b","a","b",
"a","b","a","b","a","b","a","b","a","b",
"a","b","a","b","a","b","a","b","a","b"])
sns_scatter(df, "x", "y", "grp")
figure()
sns_box(df, "grp", "y")
figure()
sns_bar(df, "grp", "y")
print("rows: " + str(rows(df)))
rows: 30
from plotting
How it works
sns_bar(df, groupcol, valuecol, [agg]) — aggregates (mean by default) valuecol within each groupcol value and plots the result as real bars (reuses Table::group_by_agg).
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.