我正在运行 JMP 17.1,并且下面显示的脚本可以正常工作,这要归功于@jthi帮助。当我运行该脚本时,我会在窗口中看到一个 Big Class.jmp 的表格框,我可以选择一行,它会返回所选行的高度和重量值。在我的现实应用程序中,我有一个更大的表,我想通过右键单击窗口并选择“过滤位置...”来过滤该表。当我在表框中获取过滤后的表时,有时选定的行返回数据,有时返回错误,提示“访问或评估 'hvals[/*###*/sel], hvals[ 时出现下标问题” /*###*/sel]”。在下面的示例中,我右键单击 Big Class Table 框并按性别筛选 == F。
关于如何检索子集表框所有行的数据有什么想法吗?
names default to here(1);
//run this now
dt = open("$sample_data\big class.jmp", invisible);
rpt = dt << select where(row() <= 10) << get as report;
tb = rpt[Table Box(1)];
tb << Set Selectable Rows();
tb << set row change function( Function( {this}, sel = this << get selected rows ) );
sel = tb << get row change function;
nw = new window("test",
v list box(
outline box("Big Class", rpt),
text box("Click 'OK' to choose height and weight"),
Button box("OK",
hvals = tb[NumberColBox("height")] << get;
wvals = tb[NumberColBox("weight")] << get;
ht = hvals[sel][1];
wt = wvals[sel][1];
print(sel, ht,wt);
)
)
);下面是原始表(Big Class 的前 10 行)的图像、按性别过滤并选择首次发生错误的行后的 Big class 表以及错误消息。请注意,该脚本适用于已筛选表的前 5 行,但不适用于第 6 行或第 7 行。