어제 다음 스레드를 발견하여 parse()를 조사하게 되었습니다.
https://community.jmp.com/t5/Discussions/evaluating-a-string-using-a-column-formula/mp/38028
생각의 과정은 다음과 같습니다.
- expr()을 사용할 때 JMP는 다른 인수가 아닌 함수를 인수로 예상합니다. 이에 대해서는 나중에 자세히 설명합니다.
- 인수를 문자열로 변수에 저장한 다음 다른 인수나 함수에 배치할 수 있는 경우 필요한 코드를 작성하는 데 도움이 됩니다.
여기에 예가 있습니다.
names default to here(1);
clear log();
clear symbols();
dt = open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Graph Builder(
Size( 517, 447 ),
Show Control Panel( 0 ),
Fit to Window,
Set α Level( 0.05 ),
Variables( X( :weight ), Y( :height ), Color( :sex ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch(
{},
"height",
ScaleBox,
{Add Ref Line( 67.5, "Solid", "Black", "Tall", 1 )}
)
)
);스크립트는 Big Class.jmp를 연 다음 참조선이 있는 시각화를 생성합니다. 시각화를 위해 다른 소스에서 데이터를 가져오려는 경우 위의 스크립트를 다음과 같이 수정할 수 있습니다.
Names default to here(1);
clear log();
dt = open( "$SAMPLE_DATA/Big Class.jmp" );
// Example "other" source
ex = New Table( "Example",
Add Rows(2),
New Column( "Growth Label", Character, Nominal, Set Values( { "Tall", "Short" } ) ),
New Column( "Height tag", Numeric, Continuous, Set Values( { 67.5, 60 } ) ),
);
dt << Graph Builder(
Size( 517, 447 ),
Show Control Panel( 0 ),
Fit to Window,
Set α Level( 0.05 ),
Variables( X( :weight ), Y( :height ), Color( :sex ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch(
{},
"height",
ScaleBox,
{Add Ref Line( ex:Height tag[1], "Solid", "Black", ex:Growth Label[1], 1 )} // 2x references to data table( "Example" ) as "ex"
)
)
);위 스크립트의 차이점은 이제 생성된 예제 테이블에서 일부 참조선 정보를 가져오고 있다는 것입니다.위의 스크립트에서 데이터 테이블 스크립트로 시각화를 추가하려면 어떻게 해야 합니까?값에 대해 항상 다른 테이블을 참조하고 싶지 않다고 가정할 때 참조를 해당 테이블이 나타내는 값으로 대체하려면 어떻게 해야 합니까?대답은 식 조작과 겉보기에는 parse()입니다.
식 조작에 대한 자세한 내용은 다음 리소스를 참조하세요. https://www.jmp.com/support/help/en/17.0/#page/jmp/advanced-expressions-macros-and-lists.shtml#
시각화를 Big Class에 테이블 스크립트로 추가한다면 스크립트 창에는 다음과 같은 코드가 있을 것입니다.
// Visualization - No references to other data sources
dt << New script( "Vis 1",
Graph Builder(
Size( 517, 447 ),
Show Control Panel( 0 ),
Fit to Window,
Set α Level( 0.05 ),
Variables( X( :weight ), Y( :height ), Color( :sex ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch(
{},
"height",
ScaleBox,
{Add Ref Line( 67.5, "Solid", "Black", "Tall", 1 )}
)
)
);
);
// Visualization - With references to other data sources
// This will not work, as the data table reference "ex" is undefined
// We could replace ex with data table( "example" ), but that table would need to be open in the background
dt << New script( "Vis 2",
Graph Builder(
Size( 517, 447 ),
Show Control Panel( 0 ),
Fit to Window,
Set α Level( 0.05 ),
Variables( X( :weight ), Y( :height ), Color( :sex ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch(
{},
"height",
ScaleBox,
{Add Ref Line( ex:Height tag[1], "Solid", "Black", ex:Growth Label[1], 1 )}
)
)
);
);이것은 parse()에 초점을 맞춘 지금까지의 조사와 실험의 결실입니다.아직 작동하지 않지만 올바른 방향으로 나아가는 단계입니다!
names default to here(1);
clear log();
clear symbols();
// Opening & creating data tables for use
dt = open( "$SAMPLE_DATA/Big Class.jmp" );
ex = New Table( "Example",
Add Rows(2),
New Column( "Growth Label", Character, Nominal, Set Values( { "Tall", "Short" } ) ),
New Column( "Height tag", Numeric, Continuous, Set Values( { 67.5, 60 } ) ),
);
// Variables
graphing = expr( Graph Builder() );
size = "Size( 517, 447 )";
control_panel = "Show Control Panel( 0 )";
fit = "Fit to Window";
a_lvl = "Set α Level( 0.05 )";
vars = "Variables( X( :weight ), Y( :height ), Color( :sex ) )";
eles = "Elements( Points( X, Y, Legend( 3 ) ) )";
str = "SendToReport()";
disp = parse( "Dispatch()" );
curly = "{}";
label = "ex:Growth label[1]";
label2 = "height";
scle = "ScaleBox";
x_axis = "x()";
test_label = "ex:Height tag[1]";
mylabel = "ex:Growth label[1]";
ref_line = parse( "Add Ref Line()" );
insert into( graphing, parse( size ) );
insert into( graphing, parse( control_panel ) );
insert into( graphing, parse( fit ) );
insert into( graphing, parse( a_lvl ) );
insert into( graphing, parse( vars ) );
insert into( graphing, parse( eles ) );
show( graphing ); // Result:graphing = Graph Builder(Size(517, 447), Show Control Panel(0), Fit to Window, Set α Level(0.05), Variables(X(:weight), Y(:height), Color(:sex)), Elements(Points(X, Y, Legend(3))));
// add ref line
insert into( ref_line, eval( parse( test_label ) ) );
insert into( ref_line, "Solid" );
insert into( ref_line, "Black" );
insert into( ref_line, eval( parse( mylabel ) ) );
show( ref_line ); // Result: ref_line = Add Ref Line(67.5, "Solid", "Black", "Tall");
insert into( disp, parse( curley ) );
insert into( disp, eval( parse( mylabel ) ) );
insert into( disp, char( label2 ) );
insert into( disp, parse( scle ) );
insert into( disp, parse( curly ) ); // Note this line! More work needs to be done here
show( disp ); // Result: disp = Dispatch({}, "Tall", "height", ScaleBox, {});위의 스크립트는 매우 바쁘고 나머지를 파악한 후 필요한 변수의 수를 줄임으로써 최적화하는 방법을 찾을 것입니다. 이것은 꽤 목록이기 때문입니다.
스크립트 하단 근처에는 참고에 대한 자세한 정보가 있습니다. curly가 disp에 삽입되기 전에 ref_line을 curly에 삽입해야 합니다. 다음과 같이 할 수 있다고 생각하기 쉽습니다.
insert( curley, ref_line );
그러나 ref_line의 내용은 함수가 아닌 인수에 포함되어 있으므로 JMP에서 오류가 발생합니다.이 문제를 해결하는 방법이 파악되면 다른 모든 것은 쉬워야 합니다.내 다음 추측은 다음과 같이 시도하는 것입니다.
// Note: char( ref_line ) will cause JMP to error, because it's an argument
new_parse = expr( parse() );
insert into( new_parse, char( ref_line) );
// Then somehow
eval( insert into( curley, eval expr( eval( new_parse ) ) ) );
문자가 아닌 인수를 다른 인수에 삽입하는 방법을 배운 후에는 Graph Builder() 함수의 나머지 부분을 간단하게 빌드할 수 있습니다. 마지막 부분은 모든 것을 표현식으로 dt << New Script( "Visualization", );에 삽입한 다음 eval expr() 및 다른 eval() (?)을 사용하여 JMP가 성공적으로 실행되도록 하는 것입니다. 코드를 만들고 dt에 시각화를 삽입합니다.
내가 찾은 흥미로운 것이 있습니다.인수(비문자)를 다른 인수(문자)에 삽입하려고 할 때 try()는 비문자가 문자열이 되도록 도왔습니다.그러나 이것을 조금 더 테스트했을 때 결과를 복제할 수 없었습니다.또한 이러한 중괄호는 삽입하기가 매우 어렵습니다.
Names default to here(1);
clear log();
// This block demonstrates, at a basic level, what I'm trying to do
printing = Expr( print() );
hello = "hello world";
insert into( printing, hello );
eval( printing );
show( printing ); // Result = printing = Print("hello world");
// Test run 1 - Works
new_parse1 = Parse( "Variable()" );
mytest1 = "X(:height)";
insert into( new_parse1, parse( mytest1 ) );
show( new_parse1, type( mytest1 ) ); // Result: new_parse = Variable(X(:height)); Type(mytest) = "String";
// Test run 2 - Doesn't work
new_parse2 = Parse( "Variable()" );
mytest2 = X(:height); // "Name unresolved"" error! X is not recognized
insert into( new_parse2, parse( mytest2 ) );
show( new_parse2, type( mytest2 ) ); // Intended: new_parse = Variable(X(:height)); Type(mytest) = "String";
// Test run 3 - Works
new_parse3 = Parse( "Variable()" );
try( mytest3 = X(:height) );
insert into( new_parse3, parse( mytest3 ) );
show( new_parse3, type( mytest3 ) ); // Result: new_parse = Variable(X(:height)); Type(mytest) = "String";
// Test run 4 - Doesn't work
curly = "{}";
new_parse4 = Parse( "Variable()" );
x_test = parse( "X()" );
some_list = { "one", "two", "three" };
insert into( x_test, eval( some_list[1] ) );
show( x_test ); // Result: x_test = X("one");
insert into( new_parse4, x_test ); // Containing within try() avoids error, but x_test not added into new_parse3
show( new_parse3 ); // Result: new_parse3 = Variable(); <-- Intended: new_parse3 = Variable(X("one"));
insert into( curly, new_parse4 );
show( curly ); // Intended: new_parse3 = {Variable(X("one"))};
// Other attempts - Doesn't work
variable1 = Variable(X("one"));
variable2 = eval insert( "{^variable1^}" );
variable3 = "{" || char( variable1 ) || "}";내가 믿는 추가 합병증이 많이 있습니다.나는 이와 같은 것이 당신이 원하는 것이라고 믿습니다.
Names default to here(1);
clear log();
// Reference table
// Used to populate data in table script below for dt( big )
dt = New Table( "Example",
Add Rows(2),
New Column( "Growth Label", Character, Set Values( { "Tall", "Short", "Thin" } ) ),
New Column( "Height tag", Numeric, Set Values( { 67.5, 60, 56 } ) ),
New Column( "color", Character, Set Values( { "medium dark green", "medium dark red", "purple" } ) )
);
// Example table
big = open( "$SAMPLE_DATA/Big Class.jmp" );
big << New Column( "Random", Numeric, <<SET each="" value=""></SET>안녕하세요,
일부 시각화를 테이블 스크립트로 스크립팅하는 작업이 있습니다.일반적으로 이는 간단합니다. 대략적인 부분은 스크립트가 실행될 때 다른 소스를 참조해야 하는 참조선입니다.일반적으로 외부에서 변수를 허용하지 않는 두 함수에 참조가 포함되어 있기 때문에 표현식 조작을 사용하여 이러한 값을 삽입하는 방법을 찾는 것은 현재 내 기술 수준을 넘어서는 것입니다. 극복해야 할 장애물은 여러 가지가 있습니다.
- 외부 변수를 잘 받아들이지 않는 함수
- var1 = 1;
var2 = 2;
Dt << 새 스크립트( “example”, print( var1 + var2 ) ); - 변수는 테이블 스크립트 외부에서 정의됩니다. 숫자는 데이터 테이블에서 참조되므로 이는 필수 사항입니다.
- 보내다()
- 이 내부의 값은 정적이고 명확하게 명시된 값이어야 합니다.
- 함수가 포함되지 않은 표현식 작업
- 예 = expr(새 스크립트() );
제목 = “테스트”;
insert into(예: 제목); // show(예제) = 새 스크립트( “test” )
// 나중에 예제의 22번째 줄처럼 x축에 열을 삽입할 때…
x_empty = expr( X() );
x_cols = { :col1, :col2 };
insert into( x_empty, x_cols[1] ); // 오류 발생, JMP는 X()가 무엇인지 모릅니다. - 이것은 어떻게든 X()가 평가되지 않아야 하지만 여전히 항목 삽입을 허용해야 한다는 것을 말해줍니다. 이는 이름 expr() 및 expr()과 같은 작업이 수행되어야 하지만 이 경우에는 작동하지 않습니다.
예제 스크립트에는 내가 달성하려는 작업에 대한 간단한 예제가 포함되어 있습니다. 새로 생성된 테이블의 제목과 번호는 Big Class에 삽입되는 함수가 실행되기 전에 테이블 스크립트에 삽입됩니다. 스크립트 하단에 이에 대한 기본 예가 있습니다.
Names default to here(1);
clear log();
// Reference table
// Used to populate data in table script below for dt( big )
dt = New Table( "Example",
Add Rows(2),
New Column( "Growth Label", Character, Nominal, Set Values( { "Tall", "Short" } ) ),
New Column( "Height tag", Numeric, Continuous, Set Values( { 67.5, 60 } ) ),
);
// Example table
big = open( "$SAMPLE_DATA/Big Class.jmp" );
// Plain example - vis added as table script * works *
big << New Script( "Example",
Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Fit to Window,
Set α Level( 0.05 ),
Variables( X( :weight ), X( :age ), Y( :height ), Color( :sex ) ),
Elements( Points( X, Y, Legend( 4 ) ) ),
SendToReport(
Dispatch(
{},
"height",
ScaleBox,
{Add Ref Line( 67.5, "Dashed", "Medium Dark Green", "Tall", 1 ),
Add Ref Line( 60, "Dashed", "Medium Dark Red", "Short", 1 )}
)
)
)
);
// Needed info for below
vis_x = { :weight, :age };
vis_y = { :height };
// Modified example - vis added as table script * not working *
big << New Script( "Example",
Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Fit to Window,
Set α Level( 0.05 ),
Variables( X( vis_x[1] ), X( vis_x[1] ), Y( vis_y[1] ), Color( :sex ) ),
Elements( Points( X, Y, Legend( 4 ) ) ),
SendToReport(
Dispatch(
{},
"height",
ScaleBox,
{Add Ref Line( big:Height tag[1], "Dashed", "Medium Dark Green", big:Growth Label[1], 1 ),
Add Ref Line( big:Height tag[2], "Dashed", "Medium Dark Red", big:Growth Label[2], 1 )}
)
)
)
);
// Example: expression manipulations
var1 = 10; // represents some reference number, from somewhere
var2 = 1; // represents some reference number, from somewhere
expr_test = eval expr( expr(var1) + expr(var2) );
expr_begin = expr( New Script( "Var replacement" ) );
insert into( expr_begin, name expr( expr_test ) );
show( expr_begin );
eval( eval expr( big << expr( name expr( expr_begin ) ) ) ); // Script contains: 10 + 1
/* Notice how the table script "Var replacement" in big doesn't contain var1 & var2,
it contains the values they represent. This is what I want to do. */
close( dt, "No Save" );커뮤니티 포럼에서 "참조선"을 검색하면 꽤 많은 결과가 나옵니다. 지금까지 내가 찾은 가장 가까운 예는 아래 링크입니다.
https://community.jmp.com/t5/Discussions/Is-there-a-way-to-automatically-draw-ref-lines-at-the-peak-of/mp/87721/highlight/false#M38710
https://community.jmp.com/t5/Discussions/Fill-color-for-multiple-reference-lines/mp/273205