你好,
我的任務是將一些可視化腳本編寫為表格腳本。通常這很簡單。 粗略的部分是腳本運行時需要引用其他來源的引用行。由於引用包含在兩個通常不接受外部變量的函數中,因此找出如何使用表達式操作來插入這些值目前超出了我的技能水平。 有許多障礙需要克服。
- 不能很好地接受外部變量的函數
- 變量 1 = 1;
變量 2 = 2;
Dt << New script( “example”, print( var1 + var2 ) ); - 請注意,變量是在表腳本之外定義的。 這是一項要求,因為數字將從數據表中引用。
- 派遣()
- 使用不包含函數的表達式
- 示例 = expr( 新腳本() );
標題=“測試”;
插入(例如,標題); // 顯示(示例)= 新腳本(“測試”)
// 稍後將 cols 插入 x 軸時,如示例的第 22 行......
x_empty = expr( X() );
x_cols = { :col1, :col2 };
插入(x_empty,x_cols [1]); // 出錯了,JMP 不知道 X() 是什麼 - 這告訴我 X() 需要以某種方式被取消評估,但仍然允許項目插入,這是 name expr() 和 expr() 之類的東西應該做的,但它們在這種情況下不起作用
示例腳本包含我想要完成的簡化示例。 新生成的表格中的標題和數字要插入到表格腳本中,然後再運行函數插入到大類中。 我在腳本底部有一個基本示例。
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