cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
nozellot
Level II

For Loop in "Expr" not working

Hello,
this is a representation of the script I am having a problem with:

 

n = 100;

ow = Expr(
	OneWay(Y(colPara), X(splitPara),
		MeansAndStdDev(0), AllGraphs(0), LineOfFit(0), StdDevLines(1), Legend(1), PlotQuantileByActual(1),
		SendToReport(
			Dispatch({}, "Normal Quantile Plot", OutlineBox, {SetTitle("")}),
For(l = 0, l <= n, l++, Dispatch({"Normal Quantile Plot"}, "2", ScaleBox, {Format("Best", 6), AddRefLine(l/100, "Dotted", "Black", Char(l) || "/100", 1), ) ) ) ); rep = Eval(EvalExpr(ow)) << Report;

So I am trying to create save a OneWay-Plot in an expression that will be evaluated later and turned into a report.
The first dispatch does what it is intended to do:

Dispatch({}, "Normal Quantile Plot", OutlineBox, {SetTitle("")})

However, the For Loop doesn't work and I believe it has something to do with how JMP handles running variables in combination with the Expr/Eval works.

For(l = 0, l <= n, l++, 
Dispatch({"Normal Quantile Plot"}, "2", ScaleBox, {Format("Best", 6), AddRefLine(l/100, "Dotted", "Black", Char(l) || "/100", 1),
)


Is there some sort of solution or workaround for this?
Best regards <3

 

1 REPLY 1
jthi
Super User

Re: For Loop in "Expr" not working

I would create function for this and within that function, I would move the For loop outside of the platform run.

I think something like this could work (there are plenty of other options)

Names Default To Here(1);

create_oneway = Function({dt, colpara, splitpara, n = 100}, {Default Local},
	ow = dt << OneWay(
		Y(Eval(colPara)), 
		X(Eval(splitPara)),
		MeansAndStdDev(0), 
		AllGraphs(0), 
		LineOfFit(0), 
		StdDevLines(1), 
		Legend(1), 
		PlotQuantileByActual(1)
	);
	
	rep = ow << report;
	For(l = 0, l <= n, l++,
		rep << Dispatch(
			{"Normal Quantile Plot"}, "2", ScaleBox, 
			{
				Format("Best", 6),
				Add Ref Line(l/100, "Dotted", "Black", Char(l) || "/100", 1)
			}
		);
	);
	
	rep << Dispatch({}, "Normal Quantile Plot", OutlineBox, {SetTitle("")});
	
	return(ow);
);


dt = open("$SAMPLE_DATA/Big Class.jmp");


ow = create_oneway(dt, "weight", "age");

Write();

 

You could use Expr but in that case I would build the expression from few different parts

-Jarmo

Recommended Articles