ファイルから変数を保存し、jsl スクリプトで max 関数を使用するこんにちはメンバー、
私は新しいユーザーで、JSL スクリプトを始めたばかりです。必要に応じて以下を実行する方法を提案していただけますか
私は2つのファイルを持っています、
File1 : 何千もの列 (文字列) と行 (数値) を持つデータが含まれています
File2 : file1 から関心のある列を選択するために手動で作成した列のリストがほとんど含まれていません
ファイル2のリストに基づいてmax関数を実行し、ファイル1に新しい列を作成する必要があります
以下は、私が試したコードであり、期待どおりに機能しませんでした。
dt = 開く ("C:/File2.csv")
リスト = dt << 名前を取得します。 // list = 基本的に、file1 からのいくつかのランダムな列名 = 行 1、行 2、行 10 など
dt1 = 開く ("C:/File1.jmp")
新しい列 ( "max list",Numeric,Formula (Max (list)));
データ表スクリプティングRe: ファイルから変数を保存し、jsl スクリプトで max 関数を使用するデータがどのように見えるかはわかりませんが、ここに 1 つの提案があります。 最も単純なソリューションではなく、JMP16+ が必要です
Names Default To Here(1);
dt = New Table("File2",
Add Rows(0),
Compress File When Saved(1),
New Column("Column 1", Character, "Nominal", Format("Best", 12), Set Values({"Column 1", "Column 2"}))
);
dt1 = New Table("File1",
Add Rows(3),
Compress File When Saved(1),
New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([1, 1, 1])),
New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([2, 2, 2])),
New Column("Column 3", Numeric, "Continuous", Format("Best", 12), Set Values([3, 3, 3]))
);
Show(dt << Get Name); // this will get name of the datatable not columns
max_list = Column(dt, "Column 1") << get values;
expr_max = Expr(Max());
For Each({col}, max_list,
Insert Into(expr_max, NameExpr(AsColumn(Column(dt1, col))))
);
Show(NameExpr(expr_max));
Eval(EvalExpr(
dt1 << New Column("MaxList", Numeric, Continuous, Formula(
Expr(NameExpr(expr_max))
));
));
Eval Insert、Eval Expr、Parse、および Substitute を使用して、式を別の式に挿入します。よく読むために
Re: ファイルから変数を保存し、jsl スクリプトで max 関数に使用するありがとう、テキネルソン、
出来た 。 file2 で列名 Maxlist を使用しなかったという単純な間違いを犯していました。
しかし、別のエラーが発生しました:名前空間「office1.close:today」が定義されていません。引数の間の最大値、またはリスト引数の単一の行列内の値の最大値を返します
「office1.close:today」はファイル2の1つです
file1 maxlist 列を開いて式の編集をクリックすると、エラーが発生します。
Re: ファイルから変数を保存し、jsl スクリプトで max 関数に使用するあなたの最新の投稿をもう一度見直しました。その投稿で明らかになった複雑な名前の問題に対処する新しいスクリプトがあると思います。
// The code below this line is the that does the calculations The code above this line would
// not normally be included
Names Default To Here( 1 );
// point to the large data table with lots of rows and columns
dt = Data Table( "Main" );
// If you are opening the table from a folder, this statement would be
// dt = open("the path to the table");
// point to the second data table that contains a list of columns to be summed
dtMax = Data Table( "config" );
// If you are opening the table from a folder, this statement would be
// dtMax = open("the path to the table");
// Just added a short pause so one can see the original tables before changing
// Create the new columns
For( i = 1, i <= N Cols( dtMax ), i++,
sumList = Column( dtMax, i ) << get values;
dt << New Column( Column( dtMax, i ) << get name );
nameList = ":\!"" || sumList[1] || "\!"n";
For( k = 2, k <= N Rows( dtMax ), k++,
Insert Into( nameList, ", :\!"" || sumList[k] || "\!"n" )
);
Column( dt, N Cols( dt ) ) << set formula( Eval( Parse( "max(" || nameList || ")" ) ) );
);Re: ファイルから変数を保存し、jsl スクリプトで max 関数を使用する
提案ありがとうございます。期待通りに動作しませんでした。何か間違っているかもしれません。より明確にするために、ファイルの外観と要件を示しました。
file1 は次のようになります (これは、office1、2、4 から最大値を見つけたいメイン テーブルです)
| オフィス1 | オフィス2 | オフィス3 | オフィス4 | オフィス5 |
| 2 | 3 | 0 | 6 | 1 |
| 3 | 2 | 6 | 4 | 4 |
| 2 | 5 | 3 | 2 | 3 |
| 1 | 0 | 2 | 3 | 2 |
| 4 | 1 | 2 | 7 | 1 |
| | | | | |
新しい列Maxlist (office1、2、4 の値)での出力が期待されます
簡単な解決策: New Column("MaxList", Numeric, Continuous, Formula(Max(:"office1",:"office2,:"office4")));
| オフィス1 | オフィス2 | オフィス3 | オフィス4 | オフィス5 | .. | マックスリスト | | |
| 2 | 3 | 0 | 6 | 1 | | 6 | | |
| 3 | 2 | 6 | 4 | 4 | | 4 | | |
| 2 | 5 | 3 | 2 | 3 | | 5 | | |
| 1 | 0 | 2 | 3 | 2 | | 3 | | |
| 4 | 1 | 2 | 7 | 1 | | 7 | | |
| | | | | | | | | |
私のmaxlistは毎日変わるので、maxlistの入力パラメータとして別のfile2を使いたいです。
file2: 入力パラメータとして指定された列名のリストとスクリプトの実行
ファイル2に最大リストを指定してファイル1で実行できるソリューションを探しています
新しい列("MaxList", 数値, 連続, 数式(Max(ファイル2 リストに基づく")));