我们通常将图形另存为脚本,以备后用。在图形涉及数据排除之前,所有方法都可以正常工作。例如,我们要绘制出(1)接受疫苗的患者与(2)未接受疫苗的患者的康复情况的图表。这两个图是相同的-变量,轴,标签和样式相同-区别在于(1)排除了(二进制)“无疫苗”条件,而(2)排除了“疫苗”条件。
我们了解,只要更改数据排除项,图形就会自动更新(这是一项功能,而不是错误)。有没有一种方法可以将数据排除项保存在图形的脚本中 ,这样每当运行脚本时,我们都会在创建图形时看到基于数据排除的结果?
有不同的方法可以做到这一点。 如果要让图表脚本针对新的数据表运行,则该脚本将要求将JSL添加到当时要进行数据选择的脚本中。 如果任务只是能够使用相同的数据表设置重新运行图,那么需要做的是创建一个类型为“行状态”的新列,然后在运行时保存行状态图的位置到新的行状态列。 然后,只需增加图形脚本即可将保存行状态从新列复制到数据表行状态,然后运行图形。
谢谢你的快速反应!
1)您能否指出如何执行此操作?“该脚本将要求将JSL添加到当时通过数据进行选择的脚本中”。
2)如果上述解决方案还允许我们在同一数据集中指定排除项,则不再赘述。否则,请为我们提供有关如何执行此操作的说明:“然后,只需增加图形脚本即可将保存行状态从新列复制到数据表行状态,然后运行图形”
或者另一种方法是将本地数据过滤器用作图形的一部分。这样,用户可以轻松地从一个组切换到另一组。
这是一个保存示例,然后使用行状态列将数据表重置回运行原始图形时的状态。
names default to here(1);
// Open a sample data table
dt = open("$SAMPLE_DATA/big class.jmp" );
// Set some exclusions and row coloring
dt << select where(:age == 12 & :sex == "F" );
dt << hide and exclude;
dt << color by column(:age);
// Run the graph to get the results desired
Graph Builder(
Size( 522, 486 ),
Show Control Panel( 0 ),
Variables( X( :age ), Group X( :sex ), Overlay( :age ) ),
Elements( Bar( X, Legend( 8 ) ) ),
SendToReport( Dispatch( {}, "400", LegendBox, {Set Title( "" )} ) )
);
// To save the data table status at the time of the graph, simply
// create a new row state column, and copy the row states to it
dt << new column("My Row States", rowstate);
dt:My Row States << copy from row states;
// To illustrate what would needed to be added to the Graph Script
// to recreate the environment it was originally run in, I will first
// clear all of the row states to bring the table back to the
// default blank row states
dt << clear row states;
// Now all that has to be done, is to copy the rowstates from the row state
// column back to the data table row states, and then rerun the graph
dt:My Row States << copy to row states;
Graph Builder(
Size( 522, 486 ),
Show Control Panel( 0 ),
Variables( X( :age ), Group X( :sex ), Overlay( :age ) ),
Elements( Bar( X, Legend( 8 ) ) ),
SendToReport( Dispatch( {}, "400", LegendBox, {Set Title( "" )} ) )
);
我认为这并不是您回答的完整答案,但是我不确定您还要求什么。 您能否重申您的要求并提供更多细节?