dt = Open( "$sample_data/big class.jmp" );
nr = N Rows( dt ); // needed below to find the end of the ascending sort list
rowsSortedByWeight = Rank( dt:weight << getvalues ); // Rank gives the indexes, ascending
heavyRows = rowsSortedByWeight[nr - 3 :: nr]; // four biggest at end
For Each( {r}, heavyRows, // get each row number into r from the heavyRows matrix
// look in the log for the report...
Write( Eval Insert( "\!nname=^dt:name[r]^ weight=^dt:weight[r]^" ) )
);
Name=KIRK Gewicht=134
Name=LESLIE Gewicht=142
Name=JACLYN Gewicht=145
Name=LAWRENCE Gewicht=172
Bearbeiten: Dies funktioniert besser mit fehlenden Werten:
dt = Open( "$sample_data/big class.jmp" );
rowsSortedByWeight = Rank( dt:weight << getvalues ); // Rank gives the indexes, ascending
nr = N Rows( rowsSortedByWeight ); // should handle missing values
heavyRows = rowsSortedByWeight[nr - 3 :: nr]; // four biggest at end
For Each( {r}, heavyRows, // get each row number into r from the heavyRows matrix
// look in the log for the report...
Write( Eval Insert( "\!nname=^dt:name[r]^ weight=^dt:weight[r]^" ) )
);
Rank() gibt eine kurze Liste ohne Indizes für fehlende Werte zurück. Verwenden Sie daher die Anzahl der Zeilen in der Rangliste und nicht die Anzahl der Zeilen in der Datentabelle.
mehr bearbeiten: Und wenn Sie die Zeilen in der Tabelle auswählen möchten,
dt << selectrows( heavyRows )
Vielen Dank an Craige_Hales für eine schnelle Antwort.
Es funktioniert gut