How to script group by to handle flexible numbers of groupsHi,
Working on automating analysis and need to make the automated generated script more generic.
The work flow is to create a summary table grouped by three columns with four columns getting derived values. That is fine.
Now I want to create oneway plots with one of the original grouping variables and also further group the plots by a second variable.
Grouping: Cycle, Step, Unique Step
4 separate Oneway by Cycle grouped Step.
The automatically generated script works on my test file fine. The issue is how to make it more generic.
If I look at the script there are specific call outs for the step column value
<<{Arrange in Rows(4)}, Where(:Step == 1), Where(:Step == 1))
And in the test case there are 19 values for step. How should I go about crafting this to be flexible to the number of steps? Various files will have different numbers of steps. What are best practices here? My desired out come is to have the four plots in a row with the grouping box also having the value of the step shown (now it is in small text after the plots) and robots to the number of steps that an incoming file might have.
Andy
dt1=Data Table( dt) <<SUMMARY></SUMMARY>
ScriptingRe: How to script group by to handle flexible numbers of groupsMade some progress.
The major amount of work could be handled by using the "By" operator.
Still what is missing is how to get the groups arranged in groups of 4 so the plots for each by grouping are on the same line.
Any thoughts
Andy
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 )} )
)
);Re: How to script group by to handle flexible numbers of groupsBelow is an example that puts the 4 graphs into a single row, and a row for each column specified in the analysis

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++;
)
)
;
Re: How to script group by to handle flexible numbers of groupsHi,
I am getting an error around the i++ call in the last bit of the code. I don't see a variable, i, initialized earlier in the code. What does it refer to?
Andy