cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
cdoraem
Level I

Use for loop on variability chart for several columns

Hi,

I have several columns in a dataset and wanted to use script to plot them in variability chart so that I can generate these plots with similar settings. But there is an error. Can someone enlighten what should be the correct syntax?

 

my script:

dt = currentdatatable();

colnames = dt << get column names( numeric );

show(colnames);

nw = New window("Plots");

for(i=5, i<nItems(colnames), i++,
test = colnames[i];

gb = Variability Chart(
    Y( as column(test) ) ,
    X( :Group, :Lot, :Wafer ),
    Max Iter( 100 ),
    Conv Limit( 0.00000001 ),
    Number Integration Abscissas( 128 ),
    Number Function Evals( 65536 ),
    Analysis Type( Name( "Choose best analysis (EMS REML Bayesian)" ) ),
    Std Dev Chart( 0 ),
    Show Box Plots(1),
)
);
nw<<append(report(gb));

 

log message:

colnames = {Lot, Wafer, X, Y, Name("4V01PC03MHVN_BF00-LT-VL_HN_11.1X1.1-VALUE_F"), Name("4V01PC03MHVN_BF00-LT-VL_HN_11.1X11.1-VALUE_F"), Name("4V01PC03MHVN_BF00-LT-VL_MN_11.1X0.76-VALUE_F"), Name("4V01PC03MHVN_BF00-LT-VL_MN_11.1X11.1-VALUE_F"), Name("4V01PC03MHVN_BF00-LT-VL_MNT_11.1X0.76-VALUE_F"), Name("4V01PC03MHVN_BF00-LT-VL_MNT_11.1X11.1-VALUE_F"), Name("4V01PC04MHVP_BF00-LT-VL_HP_0.4X1.1-VALUE_F"), Name("4V01PC04MHVP_BF00-LT-VL_HP_11.1X1.1-VALUE_F"), Name("4V01PC04MHVP_BF00-LT-VL_HP_11.1X11.1-VALUE_F"), Name("4V01PC04MHVP_BF00-LT-VL_MP_11.1X1.1-VALUE_F"), Name("4V01PC04MHVP_BF00-LT-VL_MP_11.1X11.1-VALUE_F"), Name("4V01PC06TX5V_BF00-LT-VL_N5_11.1X11.1-VALUE_F"), Name("4V01PC06TX5V_BF00-LT-VL_P5_11.1X11.1-VALUE_F"), EndTimestamp};
Not Found in access or evaluation of 'Variability Chart' , Bad Argument( {., Role requires at least 1 columns.} ), Variability Chart(/*###*/Y( As Column( test ) ),
    X( :Group, :Lot, :Wafer ),
    Max Iter( 100 ),
    Conv Limit( 0.00000001 ),
    Number Integration Abscissas( 128 ),
    Number Function Evals( 65536 ),
    Analysis Type( Name( "Choose best analysis (EMS REML Bayesian)" ) ),
    Std Dev Chart( 0 ),
    Show Box Plots( 1 )
)

In the following script, error marked by /*###*/
dt = Current Data Table();
colnames = dt << get column names( numeric );
Show( colnames );
nw = New Window( "Plots" );
For( i = 5, i < N Items( colnames ), i++,
    test = colnames[i];
    gb = Variability Chart(/*###*/Y( As Column( test ) ),
        X( :Group, :Lot, :Wafer ),
        Max Iter( 100 ),
        Conv Limit( 0.00000001 ),
        Number Integration Abscissas( 128 ),
        Number Function Evals( 65536 ),
        Analysis Type( Name( "Choose best analysis (EMS REML Bayesian)" ) ),
        Std Dev Chart( 0 ),
        Show Box Plots( 1 )
    );
);
nw << append( Report( gb ) );

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Use for loop on variability chart for several columns

I have changed your code, and I think it will work the way you want it to work.

1. I added a V List Box() to your "New Window".  This will allow you to have better control of the order of the output you want.  If you want the displays to go left to right, change to an H List Box().

2. I added the "Invisible" element to the Variability Chart.  I am assuming that what you want, is to end up with a single window with no separate widows for each chart.  

3. The As Column() would not work.  I am not sure why not!  However, changing to a Column() function worked.  Also, I eliminated the need for the "Test" variable, since it is cleaner to just have the list reference, ColNames[] right in the Variability Chart code.

4.  I am assuming that what you want is a single window with all of the output.  Your append at the end of your code would only append the last chart.  The reference to "gb" is not addative.  "gb" will be changed to each successive chart each time it is referenced in the For() loop.  Therefore, the append needs to be within the loop.

dt = Current Data Table();

colnames = dt << get column names( numeric );

Show( colnames );

nw = New Window( "Plots", myVLB = V List Box() );

For( i = 5, i < N Items( colnames ), i++, 

	gb = Variability Chart(
		invisible,
		Y( Column( colnames[i] ) ),
		X( :Group, :Lot, :Wafer ),
		Max Iter( 100 ),
		Conv Limit( 0.00000001 ),
		Number Integration Abscissas( 128 ),
		Number Function Evals( 65536 ),
		Analysis Type( Name( "Choose best analysis (EMS REML Bayesian)" ) ),
		Std Dev Chart( 0 ),
		Show Box Plots( 1 ), 

	);
	myVLB << append( Report( gb ) );
);
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Use for loop on variability chart for several columns

I have changed your code, and I think it will work the way you want it to work.

1. I added a V List Box() to your "New Window".  This will allow you to have better control of the order of the output you want.  If you want the displays to go left to right, change to an H List Box().

2. I added the "Invisible" element to the Variability Chart.  I am assuming that what you want, is to end up with a single window with no separate widows for each chart.  

3. The As Column() would not work.  I am not sure why not!  However, changing to a Column() function worked.  Also, I eliminated the need for the "Test" variable, since it is cleaner to just have the list reference, ColNames[] right in the Variability Chart code.

4.  I am assuming that what you want is a single window with all of the output.  Your append at the end of your code would only append the last chart.  The reference to "gb" is not addative.  "gb" will be changed to each successive chart each time it is referenced in the For() loop.  Therefore, the append needs to be within the loop.

dt = Current Data Table();

colnames = dt << get column names( numeric );

Show( colnames );

nw = New Window( "Plots", myVLB = V List Box() );

For( i = 5, i < N Items( colnames ), i++, 

	gb = Variability Chart(
		invisible,
		Y( Column( colnames[i] ) ),
		X( :Group, :Lot, :Wafer ),
		Max Iter( 100 ),
		Conv Limit( 0.00000001 ),
		Number Integration Abscissas( 128 ),
		Number Function Evals( 65536 ),
		Analysis Type( Name( "Choose best analysis (EMS REML Bayesian)" ) ),
		Std Dev Chart( 0 ),
		Show Box Plots( 1 ), 

	);
	myVLB << append( Report( gb ) );
);
Jim
cdoraem
Level I

Re: Use for loop on variability chart for several columns

Hi, thank you for the changes. It worked in the way i wanted.

Re: Use for loop on variability chart for several columns

There are a couple things causing the error. One is that in your For() loop, you are initializing i = 5, when I assume you would want to start with the first item in the list stored in colnames, so it should be i = 1. The second thing is that you don't need to use As Column() - you can simply use the variable name (test) that's storing the column name through each iteration, Y( test ).

 

Also, you are appending the variability chart outside of the For() loop, which means that only the last plot will be addded to the window. You want to have the last line of your code inside the loop. Hope this helps!  

cdoraem
Level I

Re: Use for loop on variability chart for several columns

Hi,

thanks for the tips. But tip#1 is not applicable as I really wanted to start at 5.