JMP Script: Column switcher applied on a coefficientHello everyone,
I am trying to make a column switcher on different calcul made by this script:
//Calcul du Zsigma
z_yyy = Eval( {<STRONG>:"Y1"n</STRONG>} );
z_xx = z_yyy[1] << get values;
z_nnn = Eval( {:Nombre de seringues} );
z_nn = z_nnn[1] << get values;
z_rrr = Eval( {:Numéro de lot} );
z_Proportion = E Div( z_xx, z_nn );
z_Pbar = V Sum( z_xx ) / V Sum( z_nn );
z_sigma_est = Root( z_Pbar * (1 - z_Pbar) );
z_zvalue = E Mult( ((z_Proportion - z_Pbar) / z_sigma_est), Root( z_nn ) );
z_nr = N Row( z_zvalue );
z_mRList = {0};
z_m = z_zvalue;
z_m[1, 0] = [];
z_m = z_m |/ [0];
z_mr = Abs( z_m - z_zvalue );
z_nr = N Row( z_mr );
z_mr[z_nr, 0] = [];
z_SigmaZ = Mean( z_mr ) / 1.128;
z_KSigmaZ = 3 * z_SigmaZ;
//And then, here is the column switcher:
Column = z_yyy << Column Switcher( :"Y1"n,{:"Y1"n, :"Y2"n, :"Y3"n, :"Y4"n ,"Y5"n ,"Y6"n});However, I get a message error because the column switcher is not applied on an object...
Do you have any suggestion for helping me?
Sebastien
ScriptingRe: JMP Script: Column switcher applied on a coefficientThe Column Switcher feature is part of a JMP platform like Graph Builder or Bivariate. It is not a feature of a matrix. It does not create a data column in a data table.
You need to create a data table with the matrix, launch a platform by assigning data columns to analysis roles, and then enable the column switcher feature.
Re: JMP Script: Column switcher applied on a coefficientHi Sebastien,
It sounds like you want JMP to update those calculations (variables) when you click on a list of columns. Is that correct? If so, the code below uses a col list box to accomplish this. The first bit is just setting up a sample table to have Y1, Y2 and Y3 columns. Then build a new window with a col list box and populate it with the list of columns. Have it so that it has a max number of columns selectable == 1. When the selection changes it will recalculate. There's a v list box() called calcVlb that you can append graphics to. When you change to the next selection it will delete the old one before replacing with the new one. Right now, it only appends a text box as an example.
names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
// New columns, update big class for y1, y2, y3
Local( {dt},
dt = Data Table( "Big Class" );
dt << New Column( "Y1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected
) << New Column( "Y2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected
) << New Column( "Y3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected
) << Begin Data Update;
For Each Row(
dt,
:Y1 = Random Integer( 1, 40 );
:Y2 = Random Integer( 1, 40 );
:Y3 = Random Integer( 1, 40 );
);
dt << End Data Update;
);
colList = {"Y1", "Y2", "Y3"};
new window("Calculations",
hlb = hlistbox(
clb = col list box(dt, max selected(1),
on change(
try(calcVlb << delete());
currCol = clb << get selected();
currColName = char(currCol[1]);
z_yyy = Eval(column(currCol));// Eval( {currCol} );
z_xx = z_yyy << get values;
z_nnn = Eval( {:weight} ); //change back
z_nn = z_nnn[1] << get values;
z_rrr = Eval( {:age} ); //change back
z_Proportion = E Div( z_xx, z_nn );
z_Pbar = V Sum( z_xx ) / V Sum( z_nn );
z_sigma_est = Root( z_Pbar * (1 - z_Pbar) );
z_zvalue = E Mult( ((z_Proportion - z_Pbar) / z_sigma_est), Root( z_nn ) );
z_nr = N Row( z_zvalue );
z_mRList = {0};
z_m = z_zvalue;
z_m[1, 0] = [];
z_m = z_m |/ [0];
z_mr = Abs( z_m - z_zvalue );
z_nr = N Row( z_mr );
z_mr[z_nr, 0] = [];
z_SigmaZ = Mean( z_mr ) / 1.128;
z_KSigmaZ = 3 * z_SigmaZ;
show(currCol[1]);
show(z_Proportion);
hlb << append(
calcVlb = vlistbox(
textbox("Variables updated to column " || currCol[1]);
)
)
)
)
)
);
clb << append(colList);
clb << set selected(1);
Re: JMP Script: Column switcher applied on a coefficientGreat! It is working on my script!
But then, I got a new problem 
The graph I made is not updated with the coefficient calculated...
Here is my example again:
colList = {"Y1", "Y2", "Y3"};
new window("Calculations",
hlb = hlistbox(
clb = col list box(dt, max selected(1),
on change(
try(calcVlb << delete());
currCol = clb << get selected();
currColName = char(currCol[1]);
z_yyy = Eval(column(currCol));// Eval( {currCol} );
z_xx = z_yyy << get values;
z_nnn = Eval( {:Nombre de seringues} );
z_nn = z_nnn[1] << get values;
z_rrr = Eval( {:Numéro de lot} );
z_Proportion = E Div( z_xx, z_nn );
z_Pbar = V Sum( z_xx ) / V Sum( z_nn );
z_sigma_est = Root( z_Pbar * (1 - z_Pbar) );
z_zvalue = E Mult( ((z_Proportion - z_Pbar) / z_sigma_est), Root( z_nn ) );
z_nr = N Row( z_zvalue );
z_mRList = {0};
z_m = z_zvalue;
z_m[1, 0] = [];
z_m = z_m |/ [0];
z_mr = Abs( z_m - z_zvalue );
z_nr = N Row( z_mr );
z_mr[z_nr, 0] = [];
z_SigmaZ = Mean( z_mr ) / 1.128;
z_KSigmaZ = 3 * z_SigmaZ;
show(currCol[1]);
show(z_Proportion);
show(z_KSigmaZ);
hlb << append(
calcVlb = vlistbox(
textbox("Variables updated to column " || currCol[1]);
)
)
)
)
)
);
// Creation des cartes
clb << append(colList);
clb << set selected(1);The z_KSigmaZ is updated as I wanted for each variable.
But then, I would like to create this graph:
Graph_exprall=Expr(
Graphall = Control Chart(
Sample Label( :Numéro de lot ),
Sample Size( :Nombre de seringues ),
KSigma(TBD),
Sort by Row Order( 1 ),
Chart Col( :"Y1"n, P( Test Beyond Limits( 1 ), Limits Precision( 1 ), LCL( -3 ) ) ),
SendToReport(
Dispatch(
{},
"P of Y1",
OutlineBox,
{Set Title( "p'-chart, Proportion de défaut" )}
),
Dispatch(
{"P of Y1"},
"2",
ScaleBox,
{Format( "Fixed Dec", 12, 5 ), Min( -0.00025 ), Max( 0.0025 ),
Inc( 0.00025 ), Minor Ticks( 1 )}
),
Dispatch(
{"P of Y1"},
"1",
ScaleBox,
{Min( 0.5 ), Inc( 1 ), Minor Ticks( 0 )}
),
Dispatch(
{"P of Y1"},
"",
AxisBox,
{Add Axis Label( "Taux de défauts (srg)" )}
)));
ColumnSwitcherObject = graphall << Column Switcher( :"Y1"n,{:"Y2"n, :"Y3"n, :"Y4"n, :"Y5"n ,"Y6"n ,"Y7"n});
);
// On affecte le SigmaZ à la carte de controle
SubstituteInto(Graph_exprall, Expr(TBD), z_KSigmaZ);
Graph_exprall;Is there a way to update the graph with the new z_KSigmaZ coefficient calculated?
I think it would better to set up the z_KSigmaZ coefficient and the variable selection within the control chart window.
Can you help me with that?
Thanks a lot.
Re: JMP Script: Column switcher applied on a coefficientSorry, this may not be very helpful. I had errors in the control chart code because the dataset isn't really suitable for a control chart and I didn't have time to debug with a proper data set. But you might be able to use this and debug the control chart code. I just tested it with the distribution platform instead of control chart and it worked ok. Keep in mind the col list box with the "on change()" code takes the place of the column switcher, so you don't need to add that to the control chart code. It just gets deleted and re-run every time you select a new parameter (column) from the col list box.
I didn't realize you also wanted plots. In that case a column switcher may have been more appropriate to use. There are ways to intercept that the selection has changed and you can run code to update your variables and re-plot. But this col list box() approach should also work ok.
names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
// New columns, update big class for y1, y2, y3
Local( {dt},
dt = Data Table( "Big Class" );
dt << New Column( "Y1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected
) << New Column( "Y2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected
) << New Column( "Y3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected
) << Begin Data Update;
For Each Row(
dt,
:Y1 = Random Integer( 1, 40 );
:Y2 = Random Integer( 1, 40 );
:Y3 = Random Integer( 1, 40 );
);
dt << End Data Update;
);
colList = {"Y1", "Y2", "Y3"};
new window("Calculations",
hlb = hlistbox(
clb = col list box(dt, max selected(1),
on change(
try(calcVlb << delete());
currCol = clb << get selected();
currColName = char(currCol[1]);
z_yyy = Eval(column(currCol));// Eval( {currCol} );
z_xx = z_yyy << get values;
z_nnn = Eval( {:weight} ); //change back
z_nn = z_nnn[1] << get values;
z_rrr = Eval( {:age} ); //change back
z_Proportion = E Div( z_xx, z_nn );
z_Pbar = V Sum( z_xx ) / V Sum( z_nn );
z_sigma_est = Root( z_Pbar * (1 - z_Pbar) );
z_zvalue = E Mult( ((z_Proportion - z_Pbar) / z_sigma_est), Root( z_nn ) );
z_nr = N Row( z_zvalue );
z_mRList = {0};
z_m = z_zvalue;
z_m[1, 0] = [];
z_m = z_m |/ [0];
z_mr = Abs( z_m - z_zvalue );
z_nr = N Row( z_mr );
z_mr[z_nr, 0] = [];
z_SigmaZ = Mean( z_mr ) / 1.128;
z_KSigmaZ = 3 * z_SigmaZ;
show(currCol[1]);
show(z_Proportion);
hlb << append(
calcVlb = vlistbox(
textbox("Variables updated to column " || currCol[1]);
)
);
calcVlb << append(
Distribution(
Stack( 1 ),
Continuous Distribution(
Column( column(currCol[1])),
Horizontal Layout( 1 ),
Vertical( 0 ),
PpK Capability Labeling( 0 ),
Customize Summary Statistics(
Std Err Mean( 0 ),
Upper Mean Confidence Interval( 0 ),
Lower Mean Confidence Interval( 0 ),
N Missing( 1 ),
Range( 1 )
)
)
);
);
//Graph_exprall=Expr(
/*
hlb << append(
Graphall = Control Chart(
Sample Label( :weight ),
Sample Size( :age ),
KSigma(z_KSigmaZ),
Sort by Row Order( 1 ),
Chart Col( column(currCol[1]), P( Test Beyond Limits( 1 ), Limits Precision( 1 ), LCL( -3 ) ) ),
SendToReport(
Dispatch(
{},
"P of Y1",
OutlineBox,
{Set Title( "p'-chart, Proportion de défaut" )}
),
Dispatch(
{"P of Y1"},
"2",
ScaleBox,
{Format( "Fixed Dec", 12, 5 ), Min( -0.00025 ), Max( 0.0025 ),
Inc( 0.00025 ), Minor Ticks( 1 )}
),
Dispatch(
{"P of Y1"},
"1",
ScaleBox,
{Min( 0.5 ), Inc( 1 ), Minor Ticks( 0 )}
),
Dispatch(
{"P of Y1"},
"",
AxisBox,
{Add Axis Label( "Taux de défauts (srg)" )}
)));
//ColumnSwitcherObject = graphall << Column Switcher( :"Y1"n,{:"Y2"n, :"Y3"n, :"Y4"n, :"Y5"n ,"Y6"n ,"Y7"n});
// );
// On affecte le SigmaZ à la carte de controle
// SubstituteInto(Graph_exprall, Expr(TBD), z_KSigmaZ);
// Graph_exprall;
);
*/
)
)
)
);
clb << append(colList);
clb << set selected(1);
Re: JMP Script: Column switcher applied on a coefficientHi,
Thanks for your answer, it helps me a lot.
And I think I am almost there.
There is only one thing that doesn't work, the z_KSigmaZ is not updated on the graph made...
Here is my code:
colList = {"Y1", "Y2", "Y3"};
new window("Calculations",
hlb = hlistbox(
clb = col list box(dt, max selected(1),
on change(
try(calcVlb << delete());
currCol = clb << get selected();
currColName = char(currCol[1]);
z_yyy = Eval(column(currCol));// Eval( {currCol} );
z_xx = z_yyy << get values;
z_nnn = Eval( {:Nombre de seringues} ); //change back
z_nn = z_nnn[1] << get values;
z_rrr = Eval( {:Numéro de lot} ); //change back
z_Proportion = E Div( z_xx, z_nn );
z_Pbar = V Sum( z_xx ) / V Sum( z_nn );
z_sigma_est = Root( z_Pbar * (1 - z_Pbar) );
z_zvalue = E Mult( ((z_Proportion - z_Pbar) / z_sigma_est), Root( z_nn ) );
z_nr = N Row( z_zvalue );
z_mRList = {0};
z_m = z_zvalue;
z_m[1, 0] = [];
z_m = z_m |/ [0];
z_mr = Abs( z_m - z_zvalue );
z_nr = N Row( z_mr );
z_mr[z_nr, 0] = [];
z_SigmaZ = Mean( z_mr ) / 1.128;
z_KSigmaZ = 3 * z_SigmaZ;
show(currCol[1]);
show(z_Proportion);
hlb << append(
calcVlb = vlistbox(
textbox("Variables updated to column " || currCol[1]);
)
);
/*calcVlb << append(
Distribution(
Stack( 1 ),
Continuous Distribution(
Column( column(currCol[1])),
Horizontal Layout( 1 ),
Vertical( 0 ),
PpK Capability Labeling( 0 ),
Customize Summary Statistics(
Std Err Mean( 0 ),
Upper Mean Confidence Interval( 0 ),
Lower Mean Confidence Interval( 0 ),
N Missing( 1 ),
Range( 1 )
)
)
);
);*/
Graph_exprall=Expr(
hlb << append(
Graphall = Control Chart(
Sample Label( :Numéro de lot ),
Sample Size( :Nombre de seringues ),
KSigma(z_KSigmaZ),
Sort by Row Order( 1 ),
Chart Col( column(currCol[1]), P( Test Beyond Limits( 1 ), Limits Precision( 1 )) ),
SendToReport(
Dispatch(
{},
"P of Y1",
OutlineBox,
{Set Title( "p'-chart, Proportion de défaut" )}
),
Dispatch(
{"P of Y1"},
"2",
ScaleBox,
{Format( "Fixed Dec", 12, 5 ), Inc( 0.00025 ), Minor Ticks( 1 )}
),
Dispatch(
{"P of Y1"},
"1",
ScaleBox,
{Min( 0.5 ), Inc( 1 ), Minor Ticks( 0 )}
),
Dispatch(
{"P of Y1"},
"",
AxisBox,
{Add Axis Label( "Taux de défauts (srg)" )}
)));
ColumnSwitcherObject = graphall << Column Switcher( :"Y1"n,{:"Y1"n, :"Y2"n, :"Y3"n});
);
);
)
)
)
);
clb << append(colList);
clb << set selected(1);
SubstituteInto(Graph_exprall, Expr(TBD), z_KSigmaZ);
Graph_exprall;The z_KSigmaZ is well calculated, however, it is not applied on the graph made...
I think it comes from the SubstituteInto(Graph_exprall, Expr(TBD), z_KSigmaZ);
Can you help me with that?
Thanks a lot.
Re: JMP Script: Column switcher applied on a coefficientI'm not sure because I don't have a dataset set up to debug it, but I changed your code in the expression and removed the TBD and replaced it with the variable itself. You can try changing it back to TBD.
KSigma(z_KSigmaZ),
Re: JMP Script: Column switcher applied on a coefficientI tried with this expression:
KSigma(TBD),
but the KSigma is not updated on the graph with the colList selected.
However the graph is updated with the column (switcher) selected.
Any idea to help me?
You will find attached a dataset exemple.