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

Eval Expr not working

Always confused by this one.  I created this formula based on one that worked previously.

 

// Get the current data table
dt = Current Data Table();

colNames = dt << get column names( continuous, string );

// Loop through all columns
For each( {col}, colNames,
Eval(
	Eval Expr(	
		New Column(
			Expr( col ) || "_Gouge",
			Numeric,
			"Continuous",
			Format( "Best", 10 ),
			Formula( (Mean( As Column( Eval(col) ) [Index(1, 100)]) + Mean(As Column(Eval(col)) [Index(N Rows() - 99, N Rows())])) / 2 - Col Minimum(As Column(Eval(col)) ) )
			);
		)
	);
);

Formula appears to remain unevaluated.


Slán



SpannerHead
1 ACCEPTED SOLUTION

Accepted Solutions
mmarchandFSLR
Level VI

Re: Eval Expr not working

As Column( Eval( col ) ) should be As Column( Expr( col ) );

View solution in original post

3 REPLIES 3
mmarchandFSLR
Level VI

Re: Eval Expr not working

As Column( Eval( col ) ) should be As Column( Expr( col ) );

SpannerHead
Level VI

Re: Eval Expr not working

Finished thing looks like this.

 

// Get the current data table
dt = Current Data Table();

colNames = dt << get column names( continuous, string );

// Loop through all columns
For each( {col}, colNames,
Eval(
	Eval Expr(	
		New Column(
			Expr( col ) || "_Gouge",
			Numeric,
			"Continuous",
			Format( "Best", 10 ),
			Formula( (Mean( As Column( Expr( col ) ) [Index(1, 100)]) + Mean(As Column( Expr( col ) ) [Index(N Rows() - 99, N Rows())])) / 2 - Col Minimum(As Column( Expr( col )) ) )
			);
		)
	);
);

Slán



SpannerHead
hogi
Level XIII

Re: Eval Expr not working

You could also use the below code. It will create column references which look as if the column was added in Formula Editor.
One of the benefits: when the input column is renamed, the formula still works.

dt = Current Data Table();

colNames = dt << get column names( continuous, string );

// Loop through all columns
For each( {col}, colNames,
Eval(
	Eval Expr(	
		New Column(
			col || "_Gouge",
			Numeric,
			"Continuous",
			Format( "Best", 10 ),
			Formula( (Mean( Expr(Name Expr(As Column(  col ) )) [Index(1, 100)]) + Mean(Expr(Name Expr(As Column(  col ) )) [Index(N Rows() - 99, N Rows())])) / 2 - Col Minimum(Expr(Name Expr(As Column(  col )) )) )
			);
		)
	);
);
	

Recommended Articles