Re: How do replace contents in the function with a placeholder?Check out Expressions -- you need to use expressions to do this. Here is an example that should work for you:
//Define variables for X, X1, X2, Y, Y1, Y2, and Group X
vars = {X(colX[i]), X(colX1[i], Position( 1 )), X(colX2[i], Position( 1 ))
,
Y(colY[i]), Y(colY1[i], Position( 1 )), Y(colY2[i], Position( 1 ))
};
If( Is Missing(colGroupX[i]) != 1,
vars = Insert Into( vars, Group X( colGroupX[i] ) )
);
vars = Substitute( vars, {}, Expr( Variables() ) );
Eval( Eval Expr(
GB = Current Data Table() << Graph Builder(
Size( 1413, 999 ),
Expr( Name Expr( vars ) ),
Elements(
Points( X( 1 ), X( 2 ), X( 3 ), Y( 1 ), Y( 2 ), Legend( 11 ) ),
Smoother( X( 1 ), X( 2 ), Y( 3 ), Y( 1 ), Y( 2 ), Legend( 14 ) )
),
SendToReport(
Dispatch( {}, "Graph", ScaleBox,
{Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
)
)
)
) )Re: How do replace contents in the function with a placeholder?Thanks for your reply, using what you have sent i tried to create a version of my own where it will add into vars if its not empty
If( Is Missing(colGroupX[i]) != 1, Insert Into( vars, Group X(colGroupX[i]))); vars = {};
If( Is Missing(colX[i]) != 1, Insert Into( vars, X(colX[i])));
If( Is Missing(colX1[i]) != 1, Insert Into( vars, X(colX1[i], Position( 1 ))));
If( Is Missing(colX2[i]) != 1, Insert Into( vars, X(colX2[i], Position( 1 ))));
If( Is Missing(colX3[i]) != 1, Insert Into( vars, X(colX3[i], Position( 1 ))));
If( Is Missing(colX4[i]) != 1, Insert Into( vars, X(colX4[i], Position( 1 ))));
If( Is Missing(colY[i]) != 1, Insert Into( vars, Y(colY[i])));
If( Is Missing(colY1[i]) != 1, Insert Into( vars, Y(colY1[i], Position( 1 ))));
If( Is Missing(colY2[i]) != 1, Insert Into( vars, Y(colY2[i], Position( 1 ))));
If( Is Missing(colY3[i]) != 1, Insert Into( vars, Y(colY3[i], Position( 1 ))));
If( Is Missing(colY4[i]) != 1, Insert Into( vars, Y(colY4[i], Position( 1 )))); <BR />
When i run it, it will have an error
Name Unresolved: X in access or evaluation of 'X' , X( colX[i] ) /*###*/
But if i include into the vars statement below it works
vars = {X(colX[i]), X(colX1[i], Position( 1 )), X(colX2[i], Position( 1 ))
,
Y(colY[i]), Y(colY1[i], Position( 1 )), Y(colY2[i], Position( 1 ))
};
Please advise thankyou !
Re: How do replace contents in the function with a placeholder?You need to insert expressions into the list. With the prototype Insert Into( var, value, position ), JMP will only perform a name-lookup on var (will not try to evaluate whatever is returned from the name lookup), will perform a name lookup and evaluate value, and will perform a name lookup and evaluate position. You want to insert an expression into the list -- thus you don't want JMP to evaluate whatever you've placed into the value position. JMP will _always_ evaluate it however, so to keep an expression even though JMP evaluates it, wrap it in an Expr() function, like this:
vars = {};
If( Is Missing(colX[i]) != 1, Insert Into( vars, Expr( X(colX[i]) )));
If( Is Missing(colX1[i]) != 1, Insert Into( vars, Expr( X(colX1[i], Position( 1 )) )));
If( Is Missing(colX2[i]) != 1, Insert Into( vars, Expr( X(colX2[i], Position( 1 )) )));
If( Is Missing(colX3[i]) != 1, Insert Into( vars, Expr( X(colX3[i], Position( 1 )) )));
If( Is Missing(colX4[i]) != 1, Insert Into( vars, Expr( X(colX4[i], Position( 1 )) )));
If( Is Missing(colY[i]) != 1, Insert Into( vars, Expr( Y(colY[i]) )));
If( Is Missing(colY1[i]) != 1, Insert Into( vars, Expr( Y(colY1[i], Position( 1 )) )));
If( Is Missing(colY2[i]) != 1, Insert Into( vars, Expr( Y(colY2[i], Position( 1 )) )));
If( Is Missing(colY3[i]) != 1, Insert Into( vars, Expr( Y(colY3[i], Position( 1 )) )));
If( Is Missing(colY4[i]) != 1, Insert Into( vars, Expr( Y(colY4[i], Position( 1 )) )));
If( Is Missing(colGroupX[i]) != 1, Insert Into( vars, Expr( Group X(colGroupX[i]) )));
Re: How do replace contents in the function with a placeholder?Are you really trying to just make graph builder dynamic? Something like this?
Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
some_func = function({dt, list_x, list_y, list_group_x={}},
{varExpr, i},
varExpr=Expr(Variables());
for(i=1, i<=nitems(list_x), i++,
insert into(varExpr, EvalExpr(X(Expr(list_x[i]))));
);
for(i=1, i<=nitems(list_y), i++,
insert into(varExpr, EvalExpr(Y(Expr(list_y[i]))));
);
for(i=1, i<=nitems(list_group_x), i++,
insert into(varExpr, EvalExpr(Group X(Expr(list_group_x[i]))));
);
Eval(Substitute(
Expr(
dt << Graph Builder(
Size( 696, 578 ),
DV_VARS
)
),
Expr(DV_VARS), nameexpr(varExpr)
))
);
some_func(dt, {:weight}, {:height, :height});
some_func(dt, {:weight, :weight}, {:height}, {:age});Re: How do replace contents in the function with a placeholder?Hi vince thanks for anwsering, this looks great. However, how do u change the type of plot to etc Line of fit or bar plot since the above method only works for smoother type plot.
Thanks!
How do replace contents in the function with a placeholder?The First chunk of code is how ill like it to work but it doesnt.
The Second chunk of code works if i replace Variables( vars ) with it
Is there a way to get the First chunk working? Please advise if im doing something wrong here thankyou. JMP16
//Define variables for X, X1, X2, Y, Y1, Y2, and Group X
vars = {X(colX[i]), X(colX1[i], Position( 1 )), X(colX2[i], Position( 1 )),
Y(colY[i]), Y(colY1[i], Position( 1 )), Y(colY2[i], Position( 1 ))<BR /> };<BR /><BR /> //If colGroupX[i] is not missing, add Group X statement to the variables block
If( Is Missing(colGroupX[i]) != 1,
vars = Insert Into( vars, Group X( colGroupX[i] ) )
);<BR /><BR />// Graph builder code where vars is inserted into the variables <BR /><BR /> GB = Current Data Table() << Graph Builder(
Size( 1413, 999 ),
Variables( vars ), // vars is placed here
Elements(
Points( X( 1 ), X( 2 ), X( 3 ), Y( 1 ), Y( 2 ), Legend( 11 ) ),
Smoother( X( 1 ), X( 2 ), Y( 3 ), Y( 1 ), Y( 2 ), Legend( 14 ) )
),
SendToReport(
Dispatch(
{},
"Graph",
ScaleBox,
{Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
)
)
);
Variables(
X(colX[i]),
X(colX1[i], Position( 1 )),
X(colX2[i], Position( 1 )),
Y(colY[i]),
Y(colY1[i], Position( 1 )),
Y(colY2[i], Position( 1 ))
),
Advanced Statistical ModelingConsumer and Market ResearchDesign of ExperimentsQuality and Process EngineeringWindows