cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
shampton82
Level VII

Can't extract the column name properly from "get Column Names"

Hey everyone,

I'm trying to get the columns names into the process capability platform and have it set the 2 normal mixture distribution as the default.  

 

So first I get the column names

(e.g. 

shampton82_0-1666474821473.png)

 

 

collist={};
collist=dt3 << Get Column Names("numeric");

 

then I loop through the columns in the capability platform:

 

nw=new window("capability analysis",
			for(i=1, i<=n items(collist),i++,
	
			dt3<<Process Capability(
				Process Variables(eval(collist[i]) & Dist( Mixture of 2 Normals )),
					Moving Range Method( Average of Moving Ranges ),
					Nonnormal Capability Method( "Z-Score"n ),
					Johnson Distribution Fit Method( Maximum Likelihood ),
					Individual Detail Reports( 1 ),
					Capability Box Plots( 0 ),
					Capability Index Plot( 0 ),
					Goal Plot(0),
				{(eval(collist[i]) & Dist( Mixture of 2 Normals )) <<
						Process Capability Analysis(
									Compare Distributions(1, <<Fit Normal,<<Fit Johnson, <<Mixture of 2 Normals, <<Fit SHASH)
						)},
				SendToReport(
					Dispatch(
						{"Individual Detail Reports",
						char(collist[i])||"(Mixture of 2 Normals) Capability", "Compare Distributions",
						"Histogram - Compare Distributions"},
						"2",
						ScaleBox
					),
					Dispatch(
						{"Individual Detail Reports",
						char(collist[i])||"(Mixture of 2 Normals) Capability", "Compare Distributions",
						"Histogram - Compare Distributions"},
						"3",
						ScaleBox
					)

				)
			)
		)
);

 

However, it is not recognizing the distribution portion selection and is thus defaulting to Normal and not checking the other distributions I'm interested in:

shampton82_1-1666474952469.png

 

Thanks for any input!

 

Steve

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Can't extract the column name properly from "get Column Names"

Most likely there are other ways to handle this, but here is one option. I had to rewrite the code a bit, because I didn't have your example data and getting this to work require some debugging. This seems to be quite strict with the format of columns (most likely due to & Dist()), so I did some Expr(NameExpr(AsColumn(Expr()))) to get correct looking column references

 

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

col_list = dt << Get Column Names(Continuous, String); // Note, these are as strings!
col_list = col_list[1::5];

nw = New Window("Capability Analysis",
	vlb_collector = V List Box()
);

col_name = col_list[1];

create_capability_expr = Expr(
	col_ref = Expr(NameExpr(AsColumn((Expr(col_name)))));
	Eval(EvalExpr(
		pc = dt << Process Capability(
			Process Variables(Expr(col_ref) & Dist(Mixture of 2 Normals)),
			Moving Range Method(Average of Moving Ranges),
			Nonnormal Capability Method("Z-Score"n),
			Johnson Distribution Fit Method(Maximum Likelihood),
			Individual Detail Reports(1),
			Capability Box Plots(0),
			Goal Plot(0),
			Capability Index Plot(0),
			Process Performance Plot(0)
		)
	));
	Eval(EvalExpr(
		pc << {(Expr(col_ref) & Dist(Mixture of 2 Normals))<< Process Capability Analysis(Compare Distributions(1, <<Fit Normal,<<Fit Johnson, <<Mixture of 2 Normals, <<Fit SHASH))};
	));
);

For Each({col_name}, col_list,
	vlb_collector << Append(create_capability_expr);	
);

jthi_0-1666509534326.png

 

Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute is strongly suggest post to read through, it helps massively with debugging also because you can just run EvalExpr()) part and see what the expression will be before evaluating it

 

Edit:

When I have to anything with columns and their references I "always" start with column names as a string and then I do what I have to with Column(), As Column(), Name Expr(), Expr()... and some combination of those. I feel like this is most robust method, easiest to to debug, works most of the time and starting point is always the same (name of column as string). It might not look like cleanest, but I don't really care when trying to reference columns in JMP as cleanliness of code isn't usually the biggest problem with that.

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Can't extract the column name properly from "get Column Names"

Most likely there are other ways to handle this, but here is one option. I had to rewrite the code a bit, because I didn't have your example data and getting this to work require some debugging. This seems to be quite strict with the format of columns (most likely due to & Dist()), so I did some Expr(NameExpr(AsColumn(Expr()))) to get correct looking column references

 

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

col_list = dt << Get Column Names(Continuous, String); // Note, these are as strings!
col_list = col_list[1::5];

nw = New Window("Capability Analysis",
	vlb_collector = V List Box()
);

col_name = col_list[1];

create_capability_expr = Expr(
	col_ref = Expr(NameExpr(AsColumn((Expr(col_name)))));
	Eval(EvalExpr(
		pc = dt << Process Capability(
			Process Variables(Expr(col_ref) & Dist(Mixture of 2 Normals)),
			Moving Range Method(Average of Moving Ranges),
			Nonnormal Capability Method("Z-Score"n),
			Johnson Distribution Fit Method(Maximum Likelihood),
			Individual Detail Reports(1),
			Capability Box Plots(0),
			Goal Plot(0),
			Capability Index Plot(0),
			Process Performance Plot(0)
		)
	));
	Eval(EvalExpr(
		pc << {(Expr(col_ref) & Dist(Mixture of 2 Normals))<< Process Capability Analysis(Compare Distributions(1, <<Fit Normal,<<Fit Johnson, <<Mixture of 2 Normals, <<Fit SHASH))};
	));
);

For Each({col_name}, col_list,
	vlb_collector << Append(create_capability_expr);	
);

jthi_0-1666509534326.png

 

Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute is strongly suggest post to read through, it helps massively with debugging also because you can just run EvalExpr()) part and see what the expression will be before evaluating it

 

Edit:

When I have to anything with columns and their references I "always" start with column names as a string and then I do what I have to with Column(), As Column(), Name Expr(), Expr()... and some combination of those. I feel like this is most robust method, easiest to to debug, works most of the time and starting point is always the same (name of column as string). It might not look like cleanest, but I don't really care when trying to reference columns in JMP as cleanliness of code isn't usually the biggest problem with that.

 

-Jarmo
shampton82
Level VII

Re: Can't extract the column name properly from "get Column Names"

 That worked great and learned a few new tricks with your code and the linked post!  Thanks for the help!

 

Steve