Use the same style of GNU R to show GDT data table - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年12月17日 15:11:35 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年12月17日 15:11:35 +0100
commit38bac83e37c24e5be164edad90650076247b2717 (patch)
tree0f8c9b8726be4a41ca698a1ba34d30ffa54fac52
parent8fcabc1b85703b6511641b257b1c6ccbb3c85638 (diff)
downloadgsl-shell-38bac83e37c24e5be164edad90650076247b2717.tar.gz
Use the same style of GNU R to show GDT data table
Diffstat
-rw-r--r--gdt.lua 16
1 files changed, 8 insertions, 8 deletions
diff --git a/gdt.lua b/gdt.lua
index 8bd3e90c..41f2a28d 100644
--- a/gdt.lua
+++ b/gdt.lua
@@ -112,7 +112,7 @@ local function gdt_table_icolumn(t, j)
end
local function val_tostr(e)
- return e and tostring(e) or ''
+ return e and tostring(e) or 'NA'
end
local function gdt_table_show(dt)
@@ -135,20 +135,20 @@ local function gdt_table_show(dt)
local lines = {}
- local t = {}
+ local row_ndig = #tostring(#dt)
+ local t = {string.rep(" ", row_ndig)}
for j = 1, c do
- t[j] = format(field_fmts[j], gdt_table_get_header(dt, j))
+ t[#t+1] = format(field_fmts[j], gdt_table_get_header(dt, j))
end
- lines[1] = '| ' .. concat(t, ' | ') .. ' |'
- lines[2] = string.rep('-', #lines[1])
+ lines[1] = concat(t, ' ')
for i = 1, r do
- local t = {}
+ local t = {format("%-" .. row_ndig .. "d", i)}
for j = 1, c do
local x = gdt_table_get(dt, i, j)
- t[j] = format(field_fmts[j], val_tostr(x))
+ t[#t+1] = format(field_fmts[j], val_tostr(x))
end
- lines[#lines + 1] = '| ' .. concat(t, ' | ') .. ' |'
+ lines[#lines + 1] = concat(t, ' ')
end
return concat(lines, '\n')
end
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月16日 14:37:03 +0000

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