cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

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

Ranking in opposite order

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
txnelson
Super User

Re: Ranking in opposite order

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

View solution in original post

Re: Ranking in opposite order

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 );

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Ranking in opposite order

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

Re: Ranking in opposite order

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 );

Recommended Articles