cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Hegedus1
Level III

How to script group by to handle flexible numbers of groups

Hi,

 

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(
	Group( :Unique Step, :Step, :Cycle ),
	Min( :"TV Pres (torr)"n ),
	Min( :"DS Pres (torr)"n ),
	Max( :"TV Pres (torr)"n ),
	Max( :"DS Pres (torr)"n ),
	Freq( "None" ),
	Weight( "None" )
);
New Window("Pressure Graphs", V List Box(
Fit Group(
Oneway(Y(:"Min(TV Pres (torr))"n), X(:Cycle), Quantiles(1), Means(1), Mean Diamonds(0), Box Plots(1), X Axis Proportional(0), Points Jittered(1), Grand Mean(0), SendToReport(Dispatch({}, "Oneway Plot", FrameBox, {DispatchSeg(BoxPlotSeg(1), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(2), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(3), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(4), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(5), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(6), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(7), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(8), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(9), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(10), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(11), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(12), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(13), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(14), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(15), {Confidence Diamond(0), Line Color("Red")})}), Dispatch({}, "Quantiles", OutlineBox, {Close(1)}), Dispatch({}, "Oneway Anova", OutlineBox, {Close(1)}), Dispatch({"Oneway Anova"}, "Analysis of Variance", OutlineBox, {Close(1)}))), 
Oneway(Y(:"Min(DS Pres (torr))"n), X(:Cycle), Quantiles(1), Means(1), Mean Diamonds(0), Box Plots(1), X Axis Proportional(0), Points Jittered(1), Grand Mean(0), SendToReport(Dispatch({}, "Oneway Plot", FrameBox, {DispatchSeg(BoxPlotSeg(1), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(2), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(3), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(4), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(5), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(6), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(7), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(8), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(9), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(10), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(11), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(12), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(13), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(14), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(15), {Confidence Diamond(0), Line Color("Red")})}), Dispatch({}, "Quantiles", OutlineBox, {Close(1)}), Dispatch({}, "Oneway Anova", OutlineBox, {Close(1)}), Dispatch({"Oneway Anova"}, "Analysis of Variance", OutlineBox, {Close(1)}))), 
Oneway(Y(:"Max(TV Pres (torr))"n), X(:Cycle), Quantiles(1), Means(1), Mean Diamonds(0), Box Plots(1), X Axis Proportional(0), Points Jittered(1), Grand Mean(0), SendToReport(Dispatch({}, "Oneway Plot", FrameBox, {DispatchSeg(BoxPlotSeg(1), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(2), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(3), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(4), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(5), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(6), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(7), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(8), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(9), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(10), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(11), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(12), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(13), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(14), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(15), {Confidence Diamond(0), Line Color("Red")})}), Dispatch({}, "Quantiles", OutlineBox, {Close(1)}), Dispatch({}, "Oneway Anova", OutlineBox, {Close(1)}), Dispatch({"Oneway Anova"}, "Analysis of Variance", OutlineBox, {Close(1)}))), 
Oneway(Y(:"Max(DS Pres (torr))"n), X(:Cycle), Quantiles(1), Means(1), Mean Diamonds(0), Box Plots(1), X Axis Proportional(0), Points Jittered(1), Grand Mean(0), SendToReport(Dispatch({}, "Oneway Plot", FrameBox, {DispatchSeg(BoxPlotSeg(1), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(2), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(3), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(4), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(5), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(6), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(7), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(8), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(9), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(10), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(11), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(12), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(13), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(14), {Confidence Diamond(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(15), {Confidence Diamond(0), Line Color("Red")})}), Dispatch({}, "Quantiles", OutlineBox, {Close(1)}), Dispatch({}, "Oneway Anova", OutlineBox, {Close(1)}), Dispatch({"Oneway Anova"}, "Analysis of Variance", OutlineBox, {Close(1)}))), 
<<{Arrange in Rows(4)}, Where(:Step == 1), Where(:Step == 1)), 
Fit Group(
Oneway(Y(:"Min(TV Pres (torr))"n), X(:Cycle), Quantiles(1), Means(1), Mean Diamonds(0), Box Plots(1), X Axis Proportional(0), Points Jittered(1), Grand Mean(0), SendToReport(Dispatch({}, "Oneway Plot", FrameBox, {DispatchSeg(BoxPlotSeg(1), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(2), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(3), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(4), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(5), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(6), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(7), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(8), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(9), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(10), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(11), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(12), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(13), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(14), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(15), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")})}), Dispatch({}, "Quantiles", OutlineBox, {Close(1)}), Dispatch({}, "Oneway Anova", OutlineBox, {Close(1)}), Dispatch({"Oneway Anova"}, "Analysis of Variance", OutlineBox, {Close(1)}))), 
Oneway(Y(:"Min(DS Pres (torr))"n), X(:Cycle), Quantiles(1), Means(1), Mean Diamonds(0), Box Plots(1), X Axis Proportional(0), Points Jittered(1), Grand Mean(0), SendToReport(Dispatch({}, "Oneway Plot", FrameBox, {DispatchSeg(BoxPlotSeg(1), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(2), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(3), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(4), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(5), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(6), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(7), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(8), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(9), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(10), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(11), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(12), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(13), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(14), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(15), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")})}), Dispatch({}, "Quantiles", OutlineBox, {Close(1)}), Dispatch({}, "Oneway Anova", OutlineBox, {Close(1)}), Dispatch({"Oneway Anova"}, "Analysis of Variance", OutlineBox, {Close(1)}))), 
Oneway(Y(:"Max(TV Pres (torr))"n), X(:Cycle), Quantiles(1), Means(1), Mean Diamonds(0), Box Plots(1), X Axis Proportional(0), Points Jittered(1), Grand Mean(0), SendToReport(Dispatch({}, "Oneway Plot", FrameBox, {DispatchSeg(BoxPlotSeg(1), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(2), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(3), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(4), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(5), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(6), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(7), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(8), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(9), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(10), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(11), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(12), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(13), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(14), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(15), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")})}), Dispatch({}, "Quantiles", OutlineBox, {Close(1)}), Dispatch({}, "Oneway Anova", OutlineBox, {Close(1)}), Dispatch({"Oneway Anova"}, "Analysis of Variance", OutlineBox, {Close(1)}))), 
Oneway(Y(:"Max(DS Pres (torr))"n), X(:Cycle), Quantiles(1), Means(1), Mean Diamonds(0), Box Plots(1), X Axis Proportional(0), Points Jittered(1), Grand Mean(0), SendToReport(Dispatch({}, "Oneway Plot", FrameBox, {DispatchSeg(BoxPlotSeg(1), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(2), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(3), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(4), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(5), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(6), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(7), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(8), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(9), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(10), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(11), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(12), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(13), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(14), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")}), DispatchSeg(BoxPlotSeg(15), {Confidence Diamond(0), Shortest Half Bracket(0), Line Color("Red")})}), Dispatch({}, "Quantiles", OutlineBox, {Close(1)}), Dispatch({}, "Oneway Anova", OutlineBox, {Close(1)}), Dispatch({"Oneway Anova"}, "Analysis of Variance", OutlineBox, {Close(1)}))), 
<<{Arrange in Rows(4)}, Where(:Step == 2), Where(:Step == 2)), 
1 ACCEPTED SOLUTION

Accepted Solutions
Hegedus1
Level III

Re: How to script group by to handle flexible numbers of groups

Hi,

Thank you very much txnelson! Made some tweaks, simplified it and got it working

I worked this a bit and came to a solution.  The arraigning of the plots can be simplified since the new window sets they receiving box to have a arrangement of 4 plots and in my case I want every four to go together in a row, I can simply fill from the start in a simple loop.  Just count the number of items and loop through and add them to the box.

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)]) 
);

 

 

Andy

View solution in original post

5 REPLIES 5
Hegedus1
Level III

Re: How to script group by to handle flexible numbers of groups

Made 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 )} )

	)
);
txnelson
Super User

Re: How to script group by to handle flexible numbers of groups

Below is an example that puts the 4 graphs into a single row, and a row for each column specified in the analysis

four.PNG

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++;
	)
)
;

Jim
Hegedus1
Level III

Re: How to script group by to handle flexible numbers of groups

Hi,
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
Hegedus1
Level III

Re: How to script group by to handle flexible numbers of groups

Hi,

Thank you very much txnelson! Made some tweaks, simplified it and got it working

I worked this a bit and came to a solution.  The arraigning of the plots can be simplified since the new window sets they receiving box to have a arrangement of 4 plots and in my case I want every four to go together in a row, I can simply fill from the start in a simple loop.  Just count the number of items and loop through and add them to the box.

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)]) 
);

 

 

Andy

Re: How to script group by to handle flexible numbers of groups

Could you use a Line Up Box?

 

New Window( "Row-Wise",
	Line Up Box( N Col(2),
		Oneway( Y( :weight ), X( :sex), By( :age ))
	)
);