式を文字列として書かずにこれを構築できますか?jsl 式を文字列として構築するのは嫌いです。トラブルシューティングが難しく、構文エラーのチェックは複数の手順を踏む必要があります。 この例のソリューション@A_Zaidの条件付きでプロットする投稿には苦労していますが。このグラフビルダー関数を構築することは可能ですか?それなし文字列を書き込んでテキストとして解析しますか? Y 引数の「式」を構築しようとすると、引数の数が不明であり、単独では解析できません。
多分そこに相当するコール、呼び出し、またはエグゼクティブR の演算子、またはスプラットまだ見つけていないPythonの演算子?
Names default to here(1);
dt = Open("$Sample_data/probe.jmp");
//Variables to hold the dynamic parts of the graph builder expresssion
Expr1 = "";
Expr2 = "";
// Pick columns to include
cols = ( dt << get column names() )[random shuffle(8::397)[1::5]];
//Populate expressions
for(c=1, c<= n items(cols), c++,
Expr1 = Expr1 || "Y( Column( \!"" || cols[c] || "\!" ), Position(1) ),";
Expr2 = Expr2 || "Y( " || char( c ) || " ),";
);
Eval( Parse( substitute(
//the graph builder script as a string with 'dummy variables' where the
//expressions created earlier will go
"gb = Graph Builder(
Size( 838, 391 ),
Variables(
X( :DELL_RPPBR ),
Expr1_
),
Elements( Line( X, Expr2_ Legend( 10 ) ) ),
Local Data Filter(
Add Filter(
columns( :DELL_RPPBR ),
Where( :DELL_RPPBR >= -1 & :DELL_RPPBR <= 0.483837991952896 )
)
)
)",
//replace the 'dummy variables'
"Expr1_",
Expr1,
"Expr2_",
Expr2
) ) );
スクリプティングRe: 式を文字列として書かずにこれを構築できますか?@Craige_Halesここであなたが提案したことの威力に気付いたのは今だけです。代用を使用して式の非連続部分を変更できることに気づきませんでした。 この方法は基本的にはR関数とはdo.callし (以下に再作成)、似ています呼び出すかエグゼクティブR の演算子、またはスプラットPython の演算子:
//call another function (f) with the arguments provided in a list (l)
do.call = function({l,f},
Substitute(
Name Expr(l),
Expr({}),
Name Expr(f)
);
);
//as an example, this calls concat("a", "b", "c")
do.call({"a","b","c"}, Expr(concat()))
良い!!
Re: 式を文字列として書かずにこれを構築できますか?の挿入するアプローチは本当に良さそうです。私はそれを覚えています。 { 式のリスト } を使用し、次のように {} を新しいヘッドに置き換えていました。
dt = Open( "$Sample_data/probe.jmp" );
// Pick columns to include
cols = (dt << get column names())[Random Shuffle( 8 :: 397 )[1 :: 5]];
//Variables to hold the dynamic parts of the graph builder expresssion
List1 = {};
List2 = {};
//Populate expressions
For( c = 1, c <= N Items( cols ), c++,
List1[c] = Eval Expr( Y( Expr( cols[c] ), Position( 1 ) ) );
List2[c] = Eval Expr( Y( Expr( c ) ) );
);
// list1: {Y( Name( "M1-TRENCH_ISO_IL" ), Position( 1 ) ), Y(...
// list2: {Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Y( 5 )}
Insert Into( List1, Expr( X( :DELL_RPPBR ) ), 1 ); // front of list1
Insert Into( List2, Expr( X ), 1 ); // front of list2
Insert Into( List2, Expr( Legend( 10 ) ) ); // back of list2
// swap the {} for variables() and line()
variablesExpr = Substitute( List1, Expr( {} ), Expr( variables() ) );
lineExpr = Substitute( List2, Expr( {} ), Expr( Line() ) );
exprGB = Expr(
//the graph builder script as a string with 'dummy variables' where the
//expressions created earlier will go
(Graph Builder(
Size( 838, 391 ),
Variables_,
Elements( Line_ ),
Local Data Filter( Add Filter( columns( :DELL_RPPBR ), Where( :DELL_RPPBR >= -1 & :DELL_RPPBR <= 0.483837991952896 ) ) )
))
);
Substitute Into( exprGB, Expr( Variables_ ), Name Expr( variablesExpr ), Expr( Line_ ), Name Expr( lineExpr ) );
Show( Name Expr( exprGB ) );
Eval( exprGB );編集...
また、InsertInto と RemoveFrom は両方とも、式内の位置で機能します。 クール、私は本当にそれを覚えておく必要があります!
Re: 式を文字列に書かずにこれを構築できますか?ああ、Insert Into() を使用して、リストの代わりに関数式を作成することは優れたソリューションです。今晩試してみます。光が見えます。ありがとうございます。
Re: 式を文字列として書かずにこれを構築できますか?ここまで来ましたが、今日はこれ以上作業できません。 Name() ディレクティブを使用した式に誤りがあります。 それを回避する方法はありますが、今は時間がありません。
Names Default To Here( 1 );
dt = Open( "$Sample_data/probe.jmp" );
//Variables to hold the dynamic parts of the graph builder expresssion
response expr = Expr(
Variables( X( :DELL_RPPBR ) )
);
line expr = Expr(
Line( X, Legend( 10 ) )
);
// Pick columns to include
col = (dt << Get Column Names)[Random Shuffle( 10 :: 397 )[1 :: 5]];
//Populate expressions
For( c = 1, c <= N Items( col ), c++,
Insert Into( response expr, Substitute( Expr( Y( Name( ccc ), Position( 1 ) ) ), Expr( ccc ), Char( col[c], 1 ) ) );
Insert Into( line expr, Substitute( Expr( Y( ccc ) ), Expr( ccc ), c ), c+1 );
);
Eval(
Substitute(
Expr(
gb = dt << Graph Builder(
Size( 838, 391 ),
Variables(
vvv
),
Elements( Line( X, lll, Legend( 10 ) ) ),
Local Data Filter(
Add Filter(
Columns( :DELL_RPPBR ),
Where( -1 < :DELL_RPPBR <= 0.483837991952896 )
)
)
)
),
Expr( vvv ), Name Expr( response expr ),
Expr( lll ), Name Expr( line expr )
)
);Re: 式を文字列として書かずにこれを構築できますか?置換や文字変換などの結果として生じる式を行内に挿入することも問題ありません。これまでと同様に、これは解釈/保守の容易さと簡潔さの間のバランスをとる行為です。 以下の例では、説明のためにこれを行っています。
式の処理は、習得 (または教育) するのが最も簡単なことではありません。 ただし、それは非常に強力であり、あなたが言及したように、メンテナンスを容易にする色分けされたテキストを保持することができます.
Names Default To Here( 1 );
dt = Open("$Sample_data/probe.jmp");
colList = {R_FUSE_16X0_5, VDP_PEMIT, "30P1_4X4_VBE"n, RM_RPB_100X7, "30N4_LE8_2RX1C_BVCBS"n}; //assume we've built this, somehow
gbExpr = Expr(
gb = Graph Builder(
Size( 838, 391 ),
_VAR_EXP_, // placeholder for Variables ( ) code.
Elements( _LINE_EXP_ ), // placeholder for Line ( ) code.
Local Data Filter( Add Filter( columns( :DELL_RPPBR ), Where( :DELL_RPPBR >= -1 & :DELL_RPPBR <= 0.483837991952896 ) ) )
)
);
varExpr = Expr( Variables( X( :DELL_RPPBR ) ) ); //Loop will insert into the last (default) position
lineExpr = Expr( Line( X, Legend( 1 ) ) ); //Loop will insert into the i+1th position
For( i = 1, i <= N Items( colList ), i++, //note we're inserting the result of a substitute ( ) in each case
Insert Into( varExpr, Substitute( Expr( Y( Column( _COL_ ), Position( 1 ) ) ), Expr( _COL_ ), Char( colList[i] ) ) );
Insert Into( lineExpr, Substitute( Expr( Y( _i_ ) ), Expr( _i_ ), i ), i + 1 );
);
Substitute Into( gbExpr, Expr( _VAR_EXP_ ), Name Expr( varExpr ), Expr( _LINE_EXP_ ), Name Expr( lineExpr ) );
gbExpr; //evaluate the (now completely built) expression to show graph
Re: 式を文字列に書かずにこれを構築できますか?私は通常、Eval(Parse()) を使用するようにフォール バックします。 これを見つけたRe: グラフ ビルダーで列の変数リストを Y 軸として使用するどこ@マークベイリー同様の解決策を提供します。
これが私の試みです:
Names Default To Here(1);
dt = Open("$Sample_data/probe.jmp");
cols = (dt << get column names())[Random Shuffle(8 :: 397)[1 :: 5]];
var expr = Expr(
Variables(X(:DELL_RPPBR))
);
var line = Expr(Line(X));
For(c = 1, c <= N Items(cols), c++,
y expr = Expr(Y(Position(1)));
Insert Into(y expr, cols[c], 1);
Insert Into(var expr, Name Expr(y expr));
yline expr = Parse("Y("||char(c)||")");
Insert Into(var line, Name Expr(yline expr));
);
yline expr = Expr(Legend(10));
Insert Into(var line, Name Expr(yline expr));
Eval(
Substitute(
Expr(
gb = dt << Graph Builder(
Size(838, 391),
Show Control Panel(0),
vvv,
Elements(yyy),
Local Data Filter(Conditional, Add Filter(columns(:DELL_RPPBR),
Where(:DELL_RPPBR >= -1 & :DELL_RPPBR <= 0.483837991952896)))
)
),
Expr(vvv), Name Expr(var expr),
Expr(yyy), Name Expr(var line)
)
);これはデバッグにはまったく役に立たないと思っていましたが、グラフビルダー生成の Substitute() 部分を実行して、何をしようとしているのかを確認できるためです (また、JSL 構文の強調表示も得られます)。
Re: 式を文字列に書かずにこれを構築できますか?Eval(Parse()) は何度も私を救ってくれました。 サンプルスクリプトの他の方法はわかりません。別のコミュニティ メンバーが解決策を持っている可能性があります