turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- JMP Basics - how to assign column values

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 27, 2017 8:56 PM
(1520 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 27, 2017 9:37 PM
(3007 views)

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

```
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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 27, 2017 9:37 PM
(3008 views)

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"}) );
```

Jim

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 28, 2017 10:40 PM
(1487 views)

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
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 29, 2017 4:27 AM
(1482 views)

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