cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
%3CLINGO-SUB%20id%3D%22lingo-sub-662314%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3EIdentifique%20las%205%20filas%20secuenciales%20m%C3%A1s%20bajas%20por%20Var%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-662314%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3E%3CP%3ESupongamos%20que%20tengo%20una%20tabla%20de%20RunNumber%20(1%2C2%2C3...)%20y%20Result%20(num%C3%A9rico%2Fcontinuo).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%C2%BFC%C3%B3mo%20puedo%20crear%20una%20columna%20de%20f%C3%B3rmula%20que%20identifique%20(por%20ejemplo%2C%20con%20un%20%221%22)%20la%20secuencia%20de%205%20n%C3%BAmeros%20con%20el%20valor%20promedio%20m%C3%A1s%20bajo%20para%20cada%20RunNumber%20y%20un%20%220%22%20en%20todos%20los%20dem%C3%A1s%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-662314%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EFusi%C3%B3n%20y%20limpieza%20de%20datos%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-662322%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3ERe%3A%20Identificar%20las%205%20filas%20secuenciales%20m%C3%A1s%20bajas%20por%20Var%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-662322%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3E%3CP%3ESi%20bien%20se%20puede%20poner%20todo%20lo%20que%20uno%20necesitar%C3%ADa%20para%20lograr%20lo%20que%20desea%20en%20una%20f%C3%B3rmula%20de%20columna%2C%20es%20mucho%20m%C3%A1s%20simple%20usar%20un%20peque%C3%B1o%20script%20ejecutado%20en%20c%C3%B3digo%20abierto.Aqu%C3%AD%20hay%20un%20ejemplo%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Enames%20default%20to%20here(1)%3B%0Adt%20%3D%20%0A%2F%2F%20Open%20Data%20Table%3A%20semiconductor%20capability.jmp%0A%2F%2F%20%E2%86%92%20Data%20Table(%20%22semiconductor%20capability%22%20)%0AOpen(%20%22%24SAMPLE_DATA%2Fsemiconductor%20capability.jmp%22%20)%3B%0A%0A%2F%2F%20create%20a%20column%20to%20represent%20the%20original%20order%20of%20the%20data%0Adt%20%26lt%3B%26lt%3B%20new%20column(%22Orig%20Row%22%2C%20set%20each%20value(row()))%3B%0A%0A%2F%2F%20Find%205%20lowest%20values%20of%20NPN1%20for%20each%20site%0Adt%20%26lt%3B%26lt%3B%20sort(%20by(%3ANPN1)%2C%20order(descending)%2C%20replace%20table(1))%3B%0A%0Adt%20%26lt%3B%26lt%3B%20new%20column(%22minimum%20NPN1%22%2C%20set%20each%20value(%0A%20if(col%20cumulative%20sum(1%2C%3Asite)%20%26lt%3B%3D%205%2C%201%2C%200)%0A))%3B%0A%0A%2F%2F%20Set%20the%20table%20back%20to%20the%20original%20order%0Adt%20%26lt%3B%26lt%3B%20sort(%20by(%3AOrig%20Row)%2C%20order(ascending)%2C%20replace%20table(1))%3B%0Adt%20%26lt%3B%26lt%3B%20delete%20columns(Orig%20Row)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
BHarris
Level VI

Identify lowest 5 sequential rows byVar

Suppose I have a table of RunNumber (1,2,3...) and Result (numeric/continuous).

 

How can I create a formula column that identifies (e.g. with a "1") the sequence of 5 Result numbers with the lowest average value for each RunNumber, and a "0" everywhere else?

1 REPLY 1
txnelson
Super User

Re: Identify lowest 5 sequential rows byVar

While putting everything one would need to accomplish what you want into a column formula could be done, it is much simpler using a little script run in open code.  Here is an example

names default to here(1);
dt = 
// Open Data Table: semiconductor capability.jmp
// → Data Table( "semiconductor capability" )
Open( "$SAMPLE_DATA/semiconductor capability.jmp" );

// create a column to represent the original order of the data
dt << new column("Orig Row", set each value(row()));

// Find 5 lowest values of NPN1 for each site
dt << sort( by(:NPN1), order(descending), replace table(1));

dt << new column("minimum NPN1", set each value(
	if(col cumulative sum(1,:site) <= 5, 1, 0)
));

// Set the table back to the original order
dt << sort( by(:Orig Row), order(ascending), replace table(1));
dt << delete columns(Orig Row);
Jim

Recommended Articles