関数内の動的列参照こんにちは、
列の特定の行を参照する関数を作成しようとしていて、任意の列名に対して実行できる場所で動的にするようにしています。サンプルとしてBig Classテーブルを使用して、高さ列で計算を実行しようとしていますが、関数にハードコードされていないと機能しません。遅れ関数も関数内では動作しないようです。
これは私が持っているスクリプトです。
dt = 開いた ( "$ SAMPLE_DATA / Big Class.jmp" ;
行()= 4;
ii = 4 ;
テスト= 関数 ({タグ}、
Y = tag [ii] - tag [ii- 1 ]; //これはうまくいきません
// Y =高さ[ii] - 高さ[ii-1];この作品
X = 遅れ (タグ、 1 ; //これはうまくいきません
// X = lag(height、1);この作品
;
テスト(身長)
前もって感謝します
関数での動的列参照下記の注釈付きのスクリプトを参照してください。
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")関数での動的列参照今、これは素晴らしいです。
どうもありがとう!心から感謝する。