我们经常将图表保存为脚本以供日后使用。在图表涉及数据排除之前,一切都运行良好。例如,我们想要绘制 (1) 接种疫苗的患者与 (2) 未接种疫苗的患者康复情况的图表。这两个图表完全相同 - 变量、轴、标签和样式相同 - 只是 (1) 排除了(二进制)“无疫苗”条件,而 (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( "" )} ) )
);
我不认为这是对您的回复的完整回答,但我不确定您还要求什么。你能重申你的要求并提供更多细节吗?
或者另一种方法是使用本地数据过滤器作为图形的一部分。 这样用户就可以轻松地从一组切换到另一组。
谢谢你的快速反应!
1)你能指出如何做到这一点的解释吗? “该脚本将要求将 JSL 添加到脚本中,该脚本会在那时通过数据进行选择”。
2)如果上面的方案也能让我们在同一个数据集中指定排除项,那就不多说了。 否则,请向我们指出如何执行此操作的解释:“然后只需扩充图形脚本即可将保存行状态从新列复制到数据表行状态,然后运行图形”
有不同的方法可以做到这一点。如果您希望图形脚本针对新数据表运行,则该脚本将需要将 JSL 添加到脚本中,该脚本会在当时遍历数据并进行选择。如果任务只是能够使用相同的数据表设置重新运行图形,那么需要做的是创建一个“行状态”类型的新列,然后在运行时保存行状态图表的新行状态列。然后图形脚本将只需要扩充以将保存行状态从新列复制到数据表行状态,然后运行图形。