我正在嘗試重新建立 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] )
);
這是結果表:

僅僅透過您發布的程式碼,我就收到了數據表 - 這不是您所期望的嗎?