我們經常將圖表儲存為腳本以供以後使用。一切都很順利,直到圖表涉及數據排除。例如,我們想要繪製 (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 添加到腳本中,該腳本會在當時遍歷數據並進行選擇。如果任務只是能夠使用相同的數據表設置重新運行圖形,那麼需要做的是創建一個“行狀態”類型的新列,然後在運行時保存行狀態圖表的新行狀態列。然後圖形腳本將只需要擴充以將保存行狀態從新列複製到數據表行狀態,然後運行圖形。