표현식을 문자열로 작성하지 않고 이것을 구성할 수 있습니까?저는 jsl 표현식을 문자열로 구성하는 것을 싫어합니다. 문제를 해결하기 어렵고 구문 오류를 확인하는 것은 다단계 프로세스입니다. 이 예시 솔루션은 @A_Zaid '에스 조건부 플로팅 포스트는 나를 힘들게 한다.이 그래프 빌더 기능을 구성할 수 있습니까? 없이 문자열을 작성하고 텍스트로 구문 분석합니까? 인수의 수를 알 수 없고 자체적으로 구문 분석할 수 없는 Y 인수의 '표현식'을 구성하려고 할 때 막혔습니다.
아마도 거기에 상응하는 두.콜 , 호출 또는 간부 R의 연산자 또는 표시 아직 찾지 못한 파이썬의 연산자?
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 기능 두.콜 하고(아래에서 다시 작성) 다음과 유사합니다. 호출하거나 간부 R의 연산자 또는 표시 파이썬의 연산자 :
//call another function (f) with the arguments provided in a list (l)
do.call = function({l,f},
Eval(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: Graph Builder에서 열의 변수 목록을 Y축으로 사용합니다. 어디 @Mark_Bailey 유사한 솔루션을 제공합니다.
이것에 대한 나의 시도는 다음과 같습니다.
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())는 너무 많은 경우에 나를 구했습니다. 귀하의 예제 스크립트에 대한 다른 방법을 모르겠습니다.다른 커뮤니티 구성원이 솔루션을 가지고 있을 수 있습니다.