問題
同じ一連の新しい数式ベースの列をデータに何度も追加したいと考えています。
解決
数式と列名をテーブルに保存します。そのテーブルからそれらを抽出します。それらをループして、ターゲットデータテーブルのペアごとに新しい列を作成しようとします。
favorite_formulas=function({dt1=currentdatatable(),FFpath},{default local},
/*
adds formulas to a data table from another data table <BR />used to store column names and respective formulas
example: favorite_formulas(currentdatatable(),"my_formulas.jmp");
FFpath must point to a file with columns "formula" and "colname" <BR />with text of desired formulas and column names
in the order they should evaluate (row 3 can use the column created by row 2, etc)
*/
try( //open setup file and get list of formulas and column names
dtFF=open(FFpath);
current data table(dtFF);
dt1 << suppressFormulaEval(true);
try(c=:colname,<BR /> wait(0);statusmsg("setup file must contain column colname");<BR /> throw ("setup file must contain column colname"));
try(c=:formula,<BR /> wait(0);statusmsg("setup file must contain column formula");<BR /> throw("setup file must contain column formula"));
CN=column("colname")<<GETVALUES></GETVALUES>議論
同じ列と形式のデータを頻繁に取得するので、毎回同じセットの新しい数式列を追加したいと考えています。これは、それを簡単にし、「お気に入りの数式」のセットをシンプルで読みやすいデータテーブルとして他のユーザーと簡単に共有できるようにするちょっとしたヒントです。私はこの関数バージョンを他の多くのスクリプト内で使用していますが、アドイン バージョンもあります。
関連項目
この機能は、JMP Pro で利用できる Formula Depot によって直接サポートされています。 「列から式を追加」を使用してテーブルから式をデポに保存し、後で「スクリプトの実行」を使用して新しいテーブルに転送します。
