Hola,
Estoy tratando de escribir una función que se refiere a una determinada fila de una columna y tratar de hacerla dinámica donde pueda ejecutarlo en cualquier nombre de columna. Utilizando la tabla Big Class como muestra, estoy tratando de ejecutar el cálculo en la columna de altura, pero no pude hacerlo funcionar a menos que esté codificado en la función. Además, la función de retraso no parece funcionar dentro de una función.
Este es el guión que tengo.
dt = Abierto ( "$ SAMPLE_DATA / Big Class.jmp" );
Fila () = 4;
ii = 4 ;
Prueba = Función ({etiqueta},
Y = etiqueta [ii] - etiqueta [ii- 1 ]; // esto no funciona
// Y = altura [ii] - altura [ii-1]; esto funciona
X = retraso (etiqueta, 1 ); // esto no funciona
// X = retraso (altura, 1); esto funciona
);
Prueba (altura)
Gracias por adelantado
Vea el guión anotado a continuación
t = Open( "$SAMPLE_DATA/Big Class.jmp" );
Row() = 4;
ii = 4;
Test = Function({tag},
Y = column(t,tag)[ii] - column(t,tag)[ii-1]; // this doesn't work
//Y = height[ii] - height[ii-1]; this works
X = lag(column(t,tag)[ii],1); // this doesn't work
//X = lag(height,1); this works
// If you want the calculated values to be returned to a value such as calling the function
// rr = Test("Height")
// uncomment the code below
//YXList = {};
//insert into(YXList,Y);
//insert into(YXList,X);
//return(YXList);
);
// If you specify
// Test(height);
// JMP will look for the value of a variable called height
// You need to pass the column name as a string and have the
// function process it
Test("height")