cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

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

JMP Scripting Noob: How to input a new column based on filtering data from two columns?

Hi all,

 

I love JMP for it's graph building tools, so I am just starting to dabble in the scripting portion of it. Can someone help me with this request?

I have two cols. One for X coordinate and one for Y coordinate. All I want to do is simply create a new col that will list Upper Right/Upper Left/Lower Right/Lower Left (LL)  based on the X and Y Coordinate...

So for example...

if 0<X<5 and 0<Y<5, label as LL

if 0<X<5 and 5<Y<10, label as UL

if 5<X<10 and 0<Y<5, label as LR

if 5<X<10 and 5<Y<10, label as UR

 

I am so lost, any help would be appreciated :)

 

schou1994_1-1612721805028.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: JMP Scripting Noob: How to input a new column based on filtering data from two columns?

You can fairly simply do this with Formulas in JMP by checking X and Y separately and concatenating them together.

 

Something like below should work (not that if the value is 0,5 or value over 10 it won't be categorized at all):

If(0 < :y < 5, "L", 5 < :y < 10, "U") || If(0 < :x < 5, "L", 5 < :x < 10, "R")
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: JMP Scripting Noob: How to input a new column based on filtering data from two columns?

You can fairly simply do this with Formulas in JMP by checking X and Y separately and concatenating them together.

 

Something like below should work (not that if the value is 0,5 or value over 10 it won't be categorized at all):

If(0 < :y < 5, "L", 5 < :y < 10, "U") || If(0 < :x < 5, "L", 5 < :x < 10, "R")
-Jarmo
txnelson
Super User

Re: JMP Scripting Noob: How to input a new column based on filtering data from two columns?

This can easily be done by finding which row has the different combinations of min and max values in the data table.

names default to here( 1 );
dt = New Table( "Sample",
	Add Rows( 4 ),
	New Column( "x",
		Set Values( [1, 1, 6, 6] )
	),
	New Column( "y",
		Set Values( [1, 6, 1, 6] )
	)
);

dt << new column("location", character, formula(
	:location[(dt << get rows where(:x==col max(:x) & :y==col max(:y)))[1]]="UR";
	:location[(dt << get rows where(:x==col max(:x) & :y==col min(:y)))[1]]="LR";
	:location[(dt << get rows where(:x==col min(:x) & :y==col max(:y)))[1]]="UL";
	:location[(dt << get rows where(:x==col min(:x) & :y==col min(:y)))[1]]="LR";
));

minmax.PNG

Jim

Recommended Articles