你好,
我的任务是将一些可视化脚本编写为表格脚本。通常这很简单。 粗略的部分是脚本运行时需要引用其他来源的引用行。由于引用包含在两个通常不接受外部变量的函数中,因此找出如何使用表达式操作来插入这些值目前超出了我的技能水平。 有许多障碍需要克服。
- 不能很好地接受外部变量的函数
- 变量 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