Implement gdt function "reduce" - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/gdt-plot.lua
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年12月17日 14:59:16 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年12月17日 14:59:16 +0100
commit9d021d645a3d8089cd14df0ef67814ba9063e681 (patch)
tree6521620ab348dcd3b825b4aad0e7b1363ae26806 /gdt-plot.lua
parentc7bff9fc26420217cbb116fbae0cea534c398e9e (diff)
downloadgsl-shell-9d021d645a3d8089cd14df0ef67814ba9063e681.tar.gz
Implement gdt function "reduce"
Diffstat (limited to 'gdt-plot.lua')
-rw-r--r--gdt-plot.lua 31
1 files changed, 31 insertions, 0 deletions
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
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月14日 05:31:40 +0000

AltStyle によって変換されたページ (->オリジナル) /