author | Francesco Abbate <francesco.bbt@gmail.com> | 2012年12月17日 14:59:16 +0100 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2012年12月17日 14:59:16 +0100 |
commit | 9d021d645a3d8089cd14df0ef67814ba9063e681 (patch) | |
tree | 6521620ab348dcd3b825b4aad0e7b1363ae26806 /gdt-plot.lua | |
parent | c7bff9fc26420217cbb116fbae0cea534c398e9e (diff) | |
download | gsl-shell-9d021d645a3d8089cd14df0ef67814ba9063e681.tar.gz |
-rw-r--r-- | gdt-plot.lua | 31 |
diff --git a/gdt-plot.lua b/gdt-plot.lua index 31d0bee0..3bbec8bc 100644 --- a/gdt-plot.lua +++ b/gdt-plot.lua @@ -226,6 +226,37 @@ local function gdt_table_xyplot(t, jx, jys, jes, opt) return plt end +local function gdt_table_reduce(t_src, jxs, jys, jes) + jxs = treat_column_refs(t_src, jxs) + jys = treat_column_refs(t_src, jys) + jes = treat_column_refs(t_src, jes) + + local labels, enums, val = rect_bin(t_src, jxs, jys, jes) + + local n, p, q = #labels, #enums, #labels[1] + local t = gdt.new(n, q + p) + + for k = 1, q do + t:set_header(k, t_src:get_header(jxs[k])) + end + for k, en in ipairs(enums) do + t:set_header(q + k, collate(en)) + end + + local set = t.set + for i = 1, n do + for k = 1, q do + set(t, i, k, labels[i][k]) + end + for k = 1, p do + set(t, i, q + k, val[i][k]) + end + end + + return t +end + gdt.barplot = gdt_table_barplot gdt.plot = gdt_table_lineplot gdt.xyplot = gdt_table_xyplot +gdt.reduce = gdt_table_reduce |