Hallo,
Ich versuche, eine Funktion zu schreiben, die sich auf eine bestimmte Zeile einer Spalte bezieht, und versuche, sie dynamisch zu machen, sodass ich sie für jeden Spaltennamen ausführen kann. Ich verwende die Big-Class-Tabelle als Beispiel und versuche, die Berechnung für die Höhenspalte auszuführen, konnte sie jedoch nicht zum Laufen bringen, es sei denn, sie ist in der Funktion fest codiert. Außerdem scheint die Verzögerungsfunktion innerhalb einer Funktion nicht zu funktionieren.
Dies ist das Skript, das ich habe.
dt = Offen ( „$SAMPLE_DATA/Big Class.jmp“ );
Zeile() = 4;
ii = 4 ;
Test = Funktion ({Etikett},
Y = tag[ii] - tag[ii- 1 ]; // das funktioniert nicht
//Y = Höhe[ii] - Höhe[ii-1]; das funktioniert
X = Verzögerung (Etikett, 1 ); // das funktioniert nicht
//X = lag(height,1); das funktioniert
);
Test(Höhe)
Dank im Voraus
Siehe das kommentierte Skript unten
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")