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
- :
- Ranking in opposite order

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

Jul 3, 2017 8:04 AM
(427 views)

Is there any way to use the Ranking function, but where the largest value gets assigned a 1? For example:

The code below, returns [3, 5, 4, 1, 2]. However, I would like it to return [3, 1, 2, 5, 4]

Ranking( [3, 6, 5, 0, 1] );

2 ACCEPTED SOLUTIONS

Accepted Solutions

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

Jul 3, 2017 8:58 AM
(833 views)

Solution

Here is a quick and dirty way to do it

```
Names Default To Here( 1 );
a = [3, 6, 5, 0, 1];
Show( Ranking( (Max( a ) + 1) - a; ) );
```

Ranking((Max(a) + 1) - a) = [3, 1, 2, 5, 4];

Jim

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

Jul 3, 2017 12:07 PM
(710 views)

Solution

I very much like Jim's solution. But I am lazy so I put the matrix and the list to work and make them carry the heavy load.

```
x = J( 10, 1, Random Normal() );
Reverse Rank = Function( { x }, { ranks },
ranks = Rank( x );
Matrix( Reverse( As List( ranks ) ) );
);
rev rank = Reverse Rank( x );
Show( x, rev rank );
```

Learn it once, use it forever!

2 REPLIES

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

Jul 3, 2017 8:58 AM
(834 views)

Here is a quick and dirty way to do it

```
Names Default To Here( 1 );
a = [3, 6, 5, 0, 1];
Show( Ranking( (Max( a ) + 1) - a; ) );
```

Ranking((Max(a) + 1) - a) = [3, 1, 2, 5, 4];

Jim

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

Jul 3, 2017 12:07 PM
(711 views)

I very much like Jim's solution. But I am lazy so I put the matrix and the list to work and make them carry the heavy load.

```
x = J( 10, 1, Random Normal() );
Reverse Rank = Function( { x }, { ranks },
ranks = Rank( x );
Matrix( Reverse( As List( ranks ) ) );
);
rev rank = Reverse Rank( x );
Show( x, rev rank );
```

Learn it once, use it forever!