後でテーブル変数を変更しても列の値を更新できるように、動的に生成されたテーブル変数名への参照を列式内に挿入するにはどうすればよいですか。 次に、未知の数の列に対してこれを実行します。
dt = Current Data Table();
NewCol = function({ColNr},
//Set a name table variable with the name of the column and RMSE appended to it
dt << Set Table Variable( concat(Column(ColNr)<< Get Name(),"RMSE"), 0 );
//Create a new column with the same name as the original column but with " with RMSE" at the end.
//Place a formula in this column which takes the original column value and add random RMSE as specified by the table variable to it.
Eval(
substitute(
expr(
dt<<NEW column=""></NEW>
挑戦してくれてありがとう、もう一度試してみて解決しました:)
おっしゃるとおり、列名の作成は正常に機能します。 新しい列式の数式部分を作成する場合は機能しません。
私がしなければならなかったのは、解析関数で列とテーブルの変数名の前後に :Name( "...") を置くことです。
dt = New Table( "Untitled 9",
Add Rows( 0 ),
New Column( "Pred Formula Thickness (A)",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[-1.09815926721176, -0.143977108758327, -1.60078929360768,
-0.340409665497429, -0.581215173360104, 0.233876291958488,
-0.357108531367114, 0.0704280592629584, 1.86236889119533,
0.669812241478143, -0.00962200322380528, 1.33041117732878,
0.533367791752501, 2.24183743599671, -0.506060621538248]
),
Set Display Width( 145 )
)
);
ColNr = 1;
//Create the table variable based on the column name with RMSE added to it.
dt << Set Table Variable( concat(column(ColNr)<< Get Name()," RMSE"), 0 );
//Create the text for the column formula. Notice that the formula stored in test is correct. It is the 'column name' + 'the table variable' multiplied with random normal.
test = ":Name( \!"" || char(column(ColNr)<< Get Name()) || "\!") + :Name( \!"" || char(column(ColNr)<< Get Name()) || " RMSE\!") * Random Normal()";
//But when putting this in a column formula equation, the parser stops parsing after the second repeat of the column name. In an ideal world I would just refer to the table variable directly.
eval(parse( "dt<<NEW column=""></NEW>
Eval(Parse()) メソッドは、複雑な列名を簡単に処理できます。 そのような問題が存在する可能性があることを認識する必要があるだけです。 これが簡単な例です
Names Default to here(1);
dt = New Table( "big class",
Add Rows( 40 ),
New Column(
"Complex column a+7/(1_2)",
Numeric,
"Continuous",
Format( "Fixed Dec", 5, 0 ),
Set Values(
[59, 61, 55, 66, 52, 60, 61, 51, 60, 61, 56, 65, 63, 58, 59, 61, 62, 65, 63,
62, 63, 64, 65, 64, 68, 64, 69, 62, 64, 67, 65, 66, 62, 66, 65, 60, 68, 62,
68, 70]
)
),
New Column(
"weight",
Numeric,
"Continuous",
Format( "Fixed Dec", 5, 0 ),
Set Values(
[95, 123, 74, 145, 64, 84, 128, 79, 112, 107, 67, 98, 105, 95, 79, 81, 91,
142, 84, 85, 93, 99, 119, 92, 112, 99, 113, 92, 112, 128, 111, 105, 104,
106, 112, 115, 128, 116, 134, 172]
)
)
);
col names = dt<<GET column="" names=""></GET>
parse(eval()) メソッドはテーブル変数名または列名の () を適切に処理できないため、より堅牢な解決策をまだ探しています。
ああなるほど。 列名をその場で生成しているので、使用できる戦略がいくつかあります。
1 つ目は、実行時に生成する列名のリストに対して、いくつかの「substitute into()」コマンドを使用することです。 通常、これはほとんどの場合にうまく機能します。
2 番目に、Eval(Parse()) メソッドを使用できます。このメソッドでは、連結コマンドを使用してプログラムで JSL の文字列を構築します。 これが私の特効薬です。 特に列のプロパティと操作に関連するものです。 スクリプトは基本的に完成したコマンドを文字列として「入力」し、それを式に変換するため、余分な Eval() コマンドがすべて不要になります。 あとは式を実行するだけです。Re: JSL: 列式内でテーブル変数への参照を作成する方法問題は、列の数と列の名前が不明なため、列数式にテーブル変数名をハードコーディングできないことです。 テーブル変数の作成は可能です。 列の式でそれらを参照するのは難しい部分です。Re: JSL: 列式内でテーブル変数への参照を作成する方法まずテーブル変数を生成します。
dt << New Table Variable("RMSE_1", 30);
おそらく、新しい数式列を生成する前に、ループの一部としてこれを行うことになるでしょう。
その後、テーブル変数は列と同様に参照されるため、上から次のようになります。
// Add the table variable
dt << New Table Variable( "RMSE_1", 30 );
// Add the column referencing the table variable
dt << New Column( "Column 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( :RMSE_1 ^ 2 )
);
一番、
M