cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

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

Max value of each row across multiple columns JMP10

When I run below script in JMP 10, I get an error message that says - argument should be matrix{1} in access or evaluation of 'Loc Max' , Bad Argument ...

Looks like data table indexing is a feature in JMP13. What would be the work around in JMP10?

dt = New Table( "Untitled",
New Column( "a", Numeric, Set Values( [1, 33, 1] ) ),
New Column( "b", Numeric, Set Values( [2, 2, 2] ) ),
New Column( "c", Numeric, Set Values( [333, 1, 0] ) ),
New Column( "maxval", numeric ),
New Column( "maxcol", Numeric )
);

colnames = dt << getcolumnnames;

For Each Row(
r = Row();
// 1::3 means columns 1 through 3. {a,b,c} would also work.
location = Loc Max( dt[ r, 1 :: 3] ); // location of maximum value in array
maxval = dt[r, location];
maxcol = colnames[location] << getname;
);

 

Thanks!

1 REPLY 1

Re: Max value of each row across multiple columns JMP10

You can get the values as a matrix first and then grab each row from the matrix instead of the data table:

dt = New Table( "Untitled",
	New Column( "a", Numeric, Set Values( [1, 33, 1] ) ),
	New Column( "b", Numeric, Set Values( [2, 2, 2] ) ),
	New Column( "c", Numeric, Set Values( [333, 1, 0] ) ),
	New Column( "maxval", numeric ),
	New Column( "maxcol", Numeric )
);

colnames = dt << getcolumnnames;

values = dt << Get As Matrix;

For Each Row(
	r = Row();
	// 1::3 means columns 1 through 3. {a,b,c} would also work.
	location = Loc Max( values[r, 1 :: 3] ); // location of maximum value in array
	maxval = dt[r, location];
	maxcol = colnames[location] << getname;
);

Recommended Articles