Subscribe Bookmark RSS Feed

Use for loop on variability chart for several columns

cdoraem

New Contributor

Joined:

Sep 14, 2017

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

Joined:

Jun 22, 2012

Solution

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
4 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Solution

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

New Contributor

Joined:

Sep 14, 2017

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

monica_beals

Staff

Joined:

Dec 2, 2014

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

New Contributor

Joined:

Sep 14, 2017

Hi,

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