Subscribe Bookmark RSS Feed

JMP Basics - how to assign column values

jrintaz

New Contributor

Joined:

Apr 27, 2017

hi, i am new to JMP. i have a data set that defines the co-ordinates of a sqaure. Column X contains co-ordinates x-dierction and column Y has the co-orniates in y direction. I want to name the corners B,C,D,E clockwise and the cenetr of the square A in the data table only and dont want to create any graph/picture

Can anyone help with a JSL script?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

I am not sure what you actually are looking for, but if the table below is it, the script following the table will generate the corner names

corner table.PNG

Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Corner Name", character );
dt:Corner Name[dt << get rows where( :x == Col Min( :x ) & :y == Col Min( :y ) )] = "B";
dt:Corner Name[dt << get rows where( :x == Col Min( :x ) & :y == Col Max( :y ) )] = "C";
dt:Corner Name[dt << get rows where( :x == Col Max( :x ) & :y == Col Max( :y ) )] = "D";
dt:Corner Name[dt << get rows where( :x == Col Max( :x ) & :y == Col Min( :y ) )] = "E";
dt:Corner Name[dt << get rows where( :x == Col Mean( :x ) & :y == Col Mean( :y ) )] = "A";
// OR
dt << New Column( "Corner Name 2", character );
dt:Corner Name 2[1] = "B";
dt:Corner Name 2[2] = "C";
dt:Corner Name 2[3] = "D";
dt:Corner Name 2[4] = "E";
dt:Corner Name 2[5] = "A";
// OR
dt << New Column( "Corner Name  3", character, values({"B","C","D","E","A"}) );
Jim
3 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Solution

I am not sure what you actually are looking for, but if the table below is it, the script following the table will generate the corner names

corner table.PNG

Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Corner Name", character );
dt:Corner Name[dt << get rows where( :x == Col Min( :x ) & :y == Col Min( :y ) )] = "B";
dt:Corner Name[dt << get rows where( :x == Col Min( :x ) & :y == Col Max( :y ) )] = "C";
dt:Corner Name[dt << get rows where( :x == Col Max( :x ) & :y == Col Max( :y ) )] = "D";
dt:Corner Name[dt << get rows where( :x == Col Max( :x ) & :y == Col Min( :y ) )] = "E";
dt:Corner Name[dt << get rows where( :x == Col Mean( :x ) & :y == Col Mean( :y ) )] = "A";
// OR
dt << New Column( "Corner Name 2", character );
dt:Corner Name 2[1] = "B";
dt:Corner Name 2[2] = "C";
dt:Corner Name 2[3] = "D";
dt:Corner Name 2[4] = "E";
dt:Corner Name 2[5] = "A";
// OR
dt << New Column( "Corner Name  3", character, values({"B","C","D","E","A"}) );
Jim
jrintaz

New Contributor

Joined:

Apr 27, 2017

Thank you for the quick response! I like solution 1 better and that was what I was looking for.

To get to a step further, my data looks like this and i have to define 2 conditional statements for 2 different scenarios.

1. When data has only 1 A corner at the center of the square

2. When data has 2 points at the center call them: A-Top and A-bottom (with the same X-cordinate)

Depending on the data present in the data table, I am trying to write the script to name the corners like below (in that order).

 

X1Y1CornersY1Y2Corners
-7029102B-2526338B
1569-18C1615-18C
920215299A92649272A-Bottom
1478430692D926418563A-Top
164241572E1558527929D
   172261572E

If you can share the script, it would be helpful.

Thanks!

txnelson

Super User

Joined:

Jun 22, 2012

corners 1.PNGcorners 2.PNG

The new data you provided do not meet the assumptions that I had made in creating the original scripts I provided.  I had assumed a square, with the X and Y coordinates being definable by examining the extreme values and for center points, the true center(mean).  You had also indicated the corners would be in a clockwise order, (B,C,D,E).  As can be seen in the graphs above, that also is no longer true.  Therefore, the only solution I can see is to hardcode the values for the corners.

Names Default To Here( 1 );
dt = Current Data Table();
If(
	Col Number( dt:x1 ) == 5,
		dt << New Column( "Corners", Character, values( {"B", "C", "A", "D", "E"} ) ) //
, // Else
	Col Number( dt:x1 ) == 6,
		dt << New Column( "Corners",
			Character,
			values( {"B", "C", "A-Bottom", "A-Top", "D", "E"} )
		)
);

 

Jim