我正在尝试重新创建 JMP 的内部行为:在分布报告中执行组合表时,生成的表将在第一列中列出按值。 当我创建自己的嵌套表结构时,我没有在生成的组合数据表中获得第一列。 如何定义窗口结构以便生成两个相同的组合数据表?
通过运行以下示例脚本来查看差异:
/* Open a sample data table */
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
/* Generate the Distribution with a By variable */
dist = dt << Distribution( Continuous Distribution( Column( :height ) ), By( :sex ) );
/* Create the combined data table of Summary Statistics */
Report( dist[1] )["Summary Statistics"][Table Box( 1 )] << Make Combined Data Table;
TestWindow = new window("Test with multiple tables",main = v list box());
main << Append(
Outline Box( "Distributions sex=F",
Outline Box( "height",
Outline Box( "Summary Statistics",
Table Box(
String Col Box("",
{"Mean", "Std Dev", "Std Err Mean", "Upper 95% Mean", "Lower 95% Mean", "N", "Sum", "Variance", "CV", "N Missing"}
),
Number Col Box("",
{60.8888888888889, 3.61189031311679, 0.851330711102296, 62.6850396850604, 59.0927380927173, 18, 1096, 13.0457516339869,
5.93193664562977, 0}
)
)
)
)
)
);
main << Append(
Outline Box( "Distributions sex=M",
Outline Box( "height",
Outline Box( "Summary Statistics",
Table Box(
String Col Box("",
{"Mean", "Std Dev", "Std Err Mean", "Upper 95% Mean", "Lower 95% Mean", "N", "Sum", "Variance", "CV", "N Missing"}
),
Number Col Box("",
{63.9090909090909, 4.3084533840777, 0.918565347870119, 65.8193521238087,
61.9988296943731, 22, 1406, 18.5627705627705, 6.7415344558826, 0}
)
)
)
)
)
);
TestWindow["Summary Statistics"][Table Box( 1 )] << Make Combined Data Table;您可以通过创建一个函数来创建组合数据表并将该函数设置为作为 TableBox 的上下文菜单脚本运行来避免这种情况。 详情请参阅下文。 请注意,如果需要,您可以使用 JSL 消息等效项添加一些其他上下文菜单项(只需做一些工作)。
customMakeCombinedDataTable = Function({},
// Get a list of all of all invisible columns
collapsedCols = TestWindow <<XPATH></XPATH>

JMP 平台生成的 TableBox 确实在内部跟踪按组,但在使用自定义 JMP 窗口时您无法自行设置。
请随时将其打开,以防万一我错过了什么!
贾斯汀,感谢您的回答,两者似乎都能解决问题,如果没有人提出更简单的解决方案,那么您绝对帮助了我! 因此,让我把这个问题再留一会儿,如果没有人提出更好的答案,我会将你的答案标记为答案。
在我看来,JMP 在内部做了其他一些事情(比如设置一个被解析的表属性?),我希望这个技巧能够暴露给脚本接口并可以在这里应用。
你好@保罗丁,
我发现有两种方法可以解决这个问题。
第一种方法是两种方法中较简单的一种,但需要将“按变量”值作为一列放入汇总统计表中。 在下面的示例中,请参阅附加的“性别”列,该列最初是折叠的,但暂时未折叠以形成组合数据表。 详情请参阅评论。
TestWindow = new window("Test with multiple tables",main = v list box());
main << Append(
Outline Box( "Distributions sex=F",
Outline Box( "height",
Outline Box( "Summary Statistics",
Table Box(
String Col Box( "Sex", Repeat( {"F"}, 10 ), <<VISIBILITY></VISIBILITY>
这是使用此方法得到的结果表:

第二种方法是从 OutlineBox 中获取按值信息并将表连接在一起。 此方法不需要对现有 OutlineBox/Sumary Statistics 设置进行任何更改,但稍微复杂一些。 详情请参阅下面的评论。
TestWindow = new window("Test with multiple tables",main = v list box());
main << Append(
Outline Box( "Distributions sex=F",
Outline Box( "height",
Outline Box( "Summary Statistics",
Table Box(
String Col Box("",
{"Mean", "Std Dev", "Std Err Mean", "Upper 95% Mean", "Lower 95% Mean", "N", "Sum", "Variance", "CV", "N Missing"}
),
Number Col Box("",
{60.8888888888889, 3.61189031311679, 0.851330711102296, 62.6850396850604, 59.0927380927173, 18, 1096, 13.0457516339869,
5.93193664562977, 0}
)
)
)
)
)
);
main << Append(
Outline Box( "Distributions sex=M",
Outline Box( "height",
Outline Box( "Summary Statistics",
Table Box(
String Col Box("",
{"Mean", "Std Dev", "Std Err Mean", "Upper 95% Mean", "Lower 95% Mean", "N", "Sum", "Variance", "CV", "N Missing"}
),
Number Col Box("",
{63.9090909090909, 4.3084533840777, 0.918565347870119, 65.8193521238087,
61.9988296943731, 22, 1406, 18.5627705627705, 6.7415344558826, 0}
)
)
)
)
)
);
// get all of the tableboxes within a 'Summary Statistics' OutlineBox
tableBoxes = TestWindow << Xpath("//OutlineBox[text()='Summary Statistics']/TableBox");
//Create and insert each data table
dts = {};
For( i = 1, i <= N Items( tableBoxes ), i++,
tempDt = tableBoxes[i] << make into data table( "invisible" );
//set the name of the table to the title of the top outlinebox
tempDt << Set Name( (((tableBoxes[i] << Parent) << parent) << parent) << get title );
Insert Into( dts, tempDt );
);
// Concatenate the tables together, with a source column
dts[1] << Concatenate( Remove( dts, 1 ), Create source column );
// close all of the temporary tables
For( i = 1, i <= N Items( dts ), i++,
Close( dts[i] )
);
这是结果表:

仅仅通过您发布的代码,我就收到了数据表 - 这不是您所期望的吗?