Subscribe Bookmark RSS Feed

Data Table Filtering

RosDima

Occasional Contributor

Joined:

Jan 17, 2017

Hi,

Please see next code.

dt = Open( "$sample_data/big class.jmp" );
ages = Data Table( "big class" ) << Summary( Group( :age ), Freq( "None" ), Weight( "None" ) );
sexes = Data Table( "big class" ) << Summary( Group( :sex ), Freq( "None" ), Weight( "None" ) );
For( iage = 1, iage <= N Rows( ages ), iage++,
thisAge = ages:age[iage];
For( isex = 1, isex <= N Rows( sexes ), isex++,
thisSex = sexes:sex[isex];
Eval(
Eval Expr(
gb = dt << Graph Builder(
Size( 508, 438 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
where( age == Expr( thisAge ) & sex == Expr( thisSex ) )
)
)
);

Please explane me purpose of  Eval( Eval Expr 

Thanks!

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

the line of code

where( age == Expr( thisAge ) & sex == Expr( thisSex ) )

has the memory variables embedded in the line.

     Eval Expr(.........)

takes all of the code with in the expression

gb = dt << Graph Builder(
	Size( 508, 438 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 5 ) ) ),
	where( age == Expr( thisAge ) & sex == Expr( thisSex ) )
)

and will evaluate it, which basically will mean in this case, that it will replace the variable "thisAge" and "thisSex" with their current values.

The outside Eval() then takes the results of the Eval Expr and runs that code

 

Jim
Wendy_Murphrey

Joined:

Jun 23, 2011

Solution

Hello, 

The Eval Expr() function searches its argument for Expr() functions.  When it locates an Expr(), it evaluates the argument and replaces it with its value.  The outer Eval() evaluates the entire expression after that evaluation and replacement occurs.   

For example from your script excerpt, when iage is 1 and isex is also 1, the code that is evaluated by Eval() looks like this to JMP: 

gb = dt << Graph Builder(
Size( 508, 438 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
where( age == 12 & sex == "F" )
)

Notice that the Where() clause above now has the variable values. 

I encourage you to take a look at the article Expression Handling Functions: Part I - Unraveling the Expr(), NameExpr(), Eval(), ... Conundrum by Joseph Morgan for a much more thorough explanation. 

I hope this is helpful!

Wendy

Wendy
2 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Solution

the line of code

where( age == Expr( thisAge ) & sex == Expr( thisSex ) )

has the memory variables embedded in the line.

     Eval Expr(.........)

takes all of the code with in the expression

gb = dt << Graph Builder(
	Size( 508, 438 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 5 ) ) ),
	where( age == Expr( thisAge ) & sex == Expr( thisSex ) )
)

and will evaluate it, which basically will mean in this case, that it will replace the variable "thisAge" and "thisSex" with their current values.

The outside Eval() then takes the results of the Eval Expr and runs that code

 

Jim
Wendy_Murphrey

Joined:

Jun 23, 2011

Solution

Hello, 

The Eval Expr() function searches its argument for Expr() functions.  When it locates an Expr(), it evaluates the argument and replaces it with its value.  The outer Eval() evaluates the entire expression after that evaluation and replacement occurs.   

For example from your script excerpt, when iage is 1 and isex is also 1, the code that is evaluated by Eval() looks like this to JMP: 

gb = dt << Graph Builder(
Size( 508, 438 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
where( age == 12 & sex == "F" )
)

Notice that the Where() clause above now has the variable values. 

I encourage you to take a look at the article Expression Handling Functions: Part I - Unraveling the Expr(), NameExpr(), Eval(), ... Conundrum by Joseph Morgan for a much more thorough explanation. 

I hope this is helpful!

Wendy

Wendy