- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
JMP Basics - how to assign column values
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?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP Basics - how to assign column values
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
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"}) );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP Basics - how to assign column values
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
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"}) );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP Basics - how to assign column values
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).
X1 | Y1 | Corners | Y1 | Y2 | Corners |
-70 | 29102 | B | -25 | 26338 | B |
1569 | -18 | C | 1615 | -18 | C |
9202 | 15299 | A | 9264 | 9272 | A-Bottom |
14784 | 30692 | D | 9264 | 18563 | A-Top |
16424 | 1572 | E | 15585 | 27929 | D |
17226 | 1572 | E |
If you can share the script, it would be helpful.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP Basics - how to assign column values
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"} )
)
);