cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
rice_ball
Level I

変数に格納されたリストを、Control Chart BuilderのYの列に読み込む複数のカラム名として定義したい。

表題を実現するJSLスクリプトの書き方を考えています。

使用するJMPのバージョンは18を利用しています。

 

dt02=current data table();

//列名を変数に
columnNames = dt02 << Get Column Names;

//3列目以降の列はすべてトレンドを確認するために必要
columnNames2={};
For( j = 3, j <= N Items( columnNames ), j++,
    Insert Into( columnNames2, Column( columnNames[j] ) ); 
);

//X-bar_and_S_chart作成
		grp01=dt02<<Control Chart Builder(
					Variables(
						Subgroup( :lotno),
						Y(
							columnNames2
					)),
					Chart(
						Position( 1 ),
						Limits( Sigma( "Standard Deviation" ), Spec Limits( 1 ) )
					),
					Chart(
						Position( 2 ),
						Points( Statistic( "Standard Deviation" ) ),
						Limits( Sigma( "Standard Deviation" ) )
					),
					Show Control Panel( 0 )
				)
					
		);
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: 変数に格納されたリストを、Control Chart BuilderのYの列に読み込む複数のカラム名として定義したい。

Seems like control chart builder wants to be one of the difficult platforms in JMP. With something like this, you should be able to get all (even the difficult/annoying ones) to work

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

cont_cols = dt << Get Column Names("Continuous", String);

ys = Expr(Y());
For Each({colname}, cont_cols,
	Insert Into(ys, Name Expr(AsColumn(dt, colname)));
);

Eval(Substitute(
	Expr(ccb = dt << Control Chart Builder(
		Variables(Subgroup(:age), _ycols_),
		Show Control Panel(0),
		Chart(Position(1), Limits(Sigma("Standard Deviation"), Spec Limits(1))),
		Chart(Position(2), Points(Statistic("Standard Deviation")), Limits(Sigma("Standard Deviation"))),
		Show Control Panel(0)
	)),
	Expr(_ycols_), Name Expr(ys)
));
-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: 変数に格納されたリストを、Control Chart BuilderのYの列に読み込む複数のカラム名として定義したい。

Seems like control chart builder wants to be one of the difficult platforms in JMP. With something like this, you should be able to get all (even the difficult/annoying ones) to work

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

cont_cols = dt << Get Column Names("Continuous", String);

ys = Expr(Y());
For Each({colname}, cont_cols,
	Insert Into(ys, Name Expr(AsColumn(dt, colname)));
);

Eval(Substitute(
	Expr(ccb = dt << Control Chart Builder(
		Variables(Subgroup(:age), _ycols_),
		Show Control Panel(0),
		Chart(Position(1), Limits(Sigma("Standard Deviation"), Spec Limits(1))),
		Chart(Position(2), Points(Statistic("Standard Deviation")), Limits(Sigma("Standard Deviation"))),
		Show Control Panel(0)
	)),
	Expr(_ycols_), Name Expr(ys)
));
-Jarmo
rice_ball
Level I

Re: 変数に格納されたリストを、Control Chart BuilderのYの列に読み込む複数のカラム名として定義したい。

素敵なコードをどうもありがとう!

問題は完全に解決できました、感謝申し上げます。

正直申し上げて、コードはまだうまく理解できていません。。。

 

イメージとしては、ysに格納した配列で、都度substituteを行い、その結果をコントロールチャート内に格納するようなイメージであったと考えます。あっておりますでしょうか?

jthi
Super User

Re: 変数に格納されたリストを、Control Chart BuilderのYの列に読み込む複数のカラム名として定義したい。

In most of the platforms you could use Eval() with list of columns but in case of control chart builder it doesn't work and you have to have very specific format to make it work Y(:col, :col2). I build the correct format into ys, Y(:height, :weight) and then use Substitute to add to the Control Chart Builder message so it will be "forced" to evaluate correctly. You can see this if you remove Eval() outside of the Substitute() and run that

jthi_0-1735128911666.png

You can also check what ys by using Show(NameExpr(ys))

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

cont_cols = dt << Get Column Names("Continuous", String);

ys = Expr(Y());
For Each({colname}, cont_cols,
	Insert Into(ys, Name Expr(AsColumn(dt, colname)));
);
Show(Name Expr(ys)); // Name Expr(ys) = Y(:height, :weight);

 

-Jarmo
hogi
Level XII

Re: 変数に格納されたリストを、Control Chart BuilderのYの列に読み込む複数のカラム名として定義したい。

either Eval(Substitute(Expr(...)))

... or Eval(Eval Expr( Expr()...))
Tips and Tricks - best practice with JMP/JSL 


Think of Eval (Eval Expr( Expr()...))as :
please search for Expr() and Eval Expr()  .... before you Eval() the whole thing.

 

Unfortunately, all 3 of them start with E... , so it's a bit tricky to remember them with the correct meaning.

The 4th E... is Name Expr()@jthi used it in the for loop to convert the Strings into columns (:column) *)
... and we need it to get Y(...) instead of an error message : )

 

*) Fortunately, Control Chart Builder accepts strings as alternative to columns.

So one can directly convert the list of column names to a Y() of column names by replacing the head via

Substitute Into:

 

 

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

tmp =  dt << Get Column Names("Continuous", String);
Substitute Into(tmp, Expr(List()), Expr(Y()));

Eval(Eval Expr(
	ccb = dt << Control Chart Builder(
		Variables(Subgroup(:age), Expr(Name Expr(tmp))),
		Show Control Panel(0),
		Chart(Position(1), Limits(Sigma("Standard Deviation"), Spec Limits(1))),
		Chart(Position(2), Points(Statistic("Standard Deviation")), Limits(Sigma("Standard Deviation"))),
		Show Control Panel(0)
	)
));