cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
] />

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
SpannerHead
Level VI

Expression Not Evaluating.

Always mystified by how to use Eval Expr correctly.  I have this pop up that asks for a wildcard column name selection and assigns it as "Divider"

nw = New Window( "Does the Data Contain Experimental Cells?",
	<<Modal,
	V List Box(
		Align( "right" ),
		H List Box(
			Panel Box( "Dividing Column", clb = Filter Col Selector( dt, all ) ),
			Panel Box( "Select Cell Identification Column",
				Lineup Box( N Col( 2 ), Spacing( 5 ),
					Button Box( "Divider", clbY << Append( clb << Get Selected ) ),
					clbY = Col List Box( MinItems( 1 ), MaxItems( 1 ), nlines( 1 ) ),
					Button Box( "Remove",
						clbY << Remove Selected;
						clbEffects << Remove Selected;
					)
				)
			)
		),
		H List Box(
			Button Box( "OK", yVars = clby << Get Items( "Column Reference" ) ),
			Button Box( "Cancel" )
		)
	)
);
Try( Divider = yVars[1] );

I then try to evaluate the object in a column formula and whatever combination of Eval(Eval Expr( I use, nothing seems to work.

If( N Items( yVars ) == 0,
	Data Table( "HIRP" ) << New Column( "Average Active Power",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			If(
				:Heater == "Reader", Col Mean( :HL_R_HEAT, :Heater ),
				Contains( :Heater, "Writer" ),
					Col Mean( :HL_W_HEAT, :Heater )
			)
		)
	),
	Eval(Eval Expr(Data Table( "HIRP" ) << New Column( "Average Active Power",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			If(
				:Heater == "Reader", Col Mean( :HL_R_HEAT, :Heater, As Column(Expr(Divider)) ),
				Contains( :Heater, "Writer" ),
					Col Mean( :HL_W_HEAT, :Heater, :HD_NUM, As Column(Expr(Divider)) )
			)
		)
	)
)));

 

 

 

 

 


Slán



SpannerHead
2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Expression Not Evaluating.

Change

As Column(Expr(Divider))

To

Expr(NameExpr(As Column(dt, Divider)))

Name Expr() isn't necessary but you will end up with "nicer looking" formulas when you use that.

Names Default To Here(1); 

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

div = "weight";
Eval(EvalExpr(
	dt << New Column("C", Numeric, Continuous, Formula(
		:Height / Expr(NameExpr(AsColumn(dt, div)))
	))
));

Also, you can test your expression evaluations by just running the EvalExpr part instead of the whole Eval(EvalExpr(...

-Jarmo

View solution in original post

SpannerHead
Level VI

Re: Expression Not Evaluating.

Needed a small tweak but worked, Thanks

If( N Items( yVars ) == 0,
	Data Table( "HIRP" ) << New Column( "Average Active Power",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			If(
				:Heater == "Reader", Col Mean( :HL_R_HEAT, :Heater ),
				Contains( :Heater, "Writer" ),
					Col Mean( :HL_W_HEAT, :Heater )
			)
		)
	),
	Eval(Eval Expr(Data Table( "HIRP" ) << New Column( "Average Active Power",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			If(
				:Heater == "Reader", Col Mean( :HL_R_HEAT, :Heater, Expr(NameExpr(As Column( Divider))) ),
				Contains( :Heater, "Writer" ),
					Col Mean( :HL_W_HEAT, :Heater, :HD_NUM, Expr(NameExpr(As Column( Divider))) )
			)
		)
	)
)));

Slán



SpannerHead

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Expression Not Evaluating.

Change

As Column(Expr(Divider))

To

Expr(NameExpr(As Column(dt, Divider)))

Name Expr() isn't necessary but you will end up with "nicer looking" formulas when you use that.

Names Default To Here(1); 

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

div = "weight";
Eval(EvalExpr(
	dt << New Column("C", Numeric, Continuous, Formula(
		:Height / Expr(NameExpr(AsColumn(dt, div)))
	))
));

Also, you can test your expression evaluations by just running the EvalExpr part instead of the whole Eval(EvalExpr(...

-Jarmo
SpannerHead
Level VI

Re: Expression Not Evaluating.

Needed a small tweak but worked, Thanks

If( N Items( yVars ) == 0,
	Data Table( "HIRP" ) << New Column( "Average Active Power",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			If(
				:Heater == "Reader", Col Mean( :HL_R_HEAT, :Heater ),
				Contains( :Heater, "Writer" ),
					Col Mean( :HL_W_HEAT, :Heater )
			)
		)
	),
	Eval(Eval Expr(Data Table( "HIRP" ) << New Column( "Average Active Power",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			If(
				:Heater == "Reader", Col Mean( :HL_R_HEAT, :Heater, Expr(NameExpr(As Column( Divider))) ),
				Contains( :Heater, "Writer" ),
					Col Mean( :HL_W_HEAT, :Heater, :HD_NUM, Expr(NameExpr(As Column( Divider))) )
			)
		)
	)
)));

Slán



SpannerHead
SpannerHead
Level VI

Re: Expression Not Evaluating.

Jarmo

 

I have something that works now but I don't understand why it works.  Is there somewhere that gives a clear description of how the evaluation methodology should be employed?  Hoping to spend less time on here searching for answers.


Slán



SpannerHead

Recommended Articles