如何編寫 group by 腳本來處理靈活數量的組你好,
致力於自動化分析,需要使自動生成的腳本更加通用。
工作流程是創建一個由三列分組的匯總表,其中四列獲取派生值。 沒事兒。
現在我想使用原始分組變量之一創建單向圖,並通過第二個變量進一步對圖進行分組。
分組:循環、步驟、獨特步驟
4 個單獨的 Oneway 按 Cycle 分組 Step。
自動生成的腳本可以很好地處理我的測試文件。 問題是如何使其更通用。
如果我查看腳本,就會發現步驟列值的具體標註
<<{按行排列(4)},Where(:Step == 1),Where(:Step == 1))
在測試用例中,step 有 19 個值。 我應該如何製作它以靈活調整步驟數? 不同的文件會有不同的步驟數。 這裡的最佳實踐是什麼? 我想要的結果是連續四個圖,分組框也具有顯示的步驟值(現在它在圖後以小文本形式顯示),並且機器人顯示傳入文件可能具有的步驟數。
安迪
dt1=Data Table( dt) <<SUMMARY></SUMMARY>
數據混合和清理回复:如何編寫 group by 腳本來處理靈活數量的組您可以使用排隊盒嗎?
New Window( "Row-Wise",
Line Up Box( N Col(2),
Oneway( Y( :weight ), X( :sex), By( :age ))
)
);
回复:如何編寫 group by 腳本來處理靈活數量的組你好,
非常感謝你,txnelson! 進行了一些調整,簡化並使其正常工作
我做了一些工作並找到了解決方案。 地塊的排列可以得到簡化,因為新窗口將接收框設置為 4 個地塊的排列,在我的例子中,我希望每四個地塊連續排列在一起,我可以簡單地從頭開始填充一個簡單的循環。 只需計算項目數量並循環並將它們添加到框中即可。
view = dt1 << Oneway(
Y( {:"Min(TV Pres (torr))"n ,:"Min(DS Pres (torr))"n,:"Max(TV Pres (torr))"n, :"Max(DS Pres (torr))"n}),
X( :Cycle ),
by (:Step),
Quantiles( 1 ),
Means( 1 ),
Mean Diamonds( 0 ),
Box Plots( 1 ),
X Axis Proportional( 0 ),
Points Jittered( 1 ),
Grand Mean( 0 ),
SendToReport(
Dispatch( {}, "Quantiles", OutlineBox, {Close( 1 )} ),
Dispatch( {}, "Oneway Anova", OutlineBox, {Close( 1 )} ),
Dispatch( {"Oneway Anova"}, "Analysis of Variance", OutlineBox, {Close( 1 )} )
)
);
nw = New Window( "test", lub = Lineup Box( N Col( 4 ) ) );
numRows = N Items( view );
For( theRow = 1, theRow <= numRows, theRow++,
lub << append( Report(view[(theRow)]) <BR /> );
安迪
回复:如何編寫 group by 腳本來處理靈活數量的組你好,
我在代碼最後一點的 i++ 調用中遇到錯誤。 我沒有看到變量 i 在代碼中之前初始化過。 它指的是什麼?
安迪回复:如何編寫 group by 腳本來處理靈活數量的組下面的示例將 4 個圖表放入一行,分析中指定的每一列對應一行

Names Default To Here( 1 );
dt1 = Open( "$SAMPLE_DATA\big class.jmp" );
// restrict to 4 ages to match the 4 level requirement
dt1 << select where( :age >= 16 );
dt1 << delete rows;
// Create a window to place the output in
nw = New Window( "test", lub = Lineup Box( N Col( 4 ) ) );
// Run the analysis with a By clause
view = dt1 << Oneway(
invisible,
Y( :height, :weight ),
X( :sex ),
Quantiles( 1 ),
Means( 1 ),
Box Plots( 1 ),
Mean Diamonds( 1 ),
by( :age ),
SendToReport(
Dispatch( {}, "Quantiles", OutlineBox, {Close( 1 )} ),
Dispatch( {}, "Oneway Anova", OutlineBox, {Close( 1 )} ),
Dispatch( {"Oneway Anova"}, "Analysis of Variance", OutlineBox, {Close( 1 )} )
)
);
// Take the elements from the outout and place in the window
// The display produces all levels of the by across one level
// of by group and then moves onto the next by group. Therefore
// the displays need to be picked across the full range of outputs
// to get the four grqaphs aligned
numCols = N Items( view ) / 4;
For( col = 1, col <= numCols, col++,
For( theRow = 1, theRow <= 4, theRow++,
lub << append( Report( view[(theRow - 1) * numCols + col] ) );
i++;
)
)
;
回复:如何編寫 group by 腳本來處理靈活數量的組取得了一些進展。
大部分工作可以通過使用“By”運算符來處理。
仍然缺少的是如何將組按 4 組排列,以便每個分組的圖位於同一條線上。
有什麼想法嗎
安迪
view = dt1 << Oneway(
Y( {:"Min(TV Pres (torr))"n ,:"Min(DS Pres (torr))"n,:"Max(TV Pres (torr))"n, :"Max(DS Pres (torr))"n}),
X( :Cycle ),
by (:Step),
Quantiles( 1 ),
Means( 1 ),
Mean Diamonds( 0 ),
Box Plots( 1 ),
X Axis Proportional( 0 ),
Points Jittered( 1 ),
Grand Mean( 0 ),
SendToReport(
Dispatch( {}, "Quantiles", OutlineBox, {Close( 1 )} ),
Dispatch( {}, "Oneway Anova", OutlineBox, {Close( 1 )} ),
Dispatch( {"Oneway Anova"}, "Analysis of Variance", OutlineBox, {Close( 1 )} )
)
);