大家好
我有「Rel Interval」、「SrID」、「Pass_Fail」欄位。我想為最後一列「更新的 Pass_Fail_SrID」建立並產生腳本。所有 SrID 在相對間隔“0”和“24”處通過,但 SrID“B”和“D”在“100”處失敗。我想建立最後一列“Updated Pass_Fail_SrID”,它引用通過和失敗並將通過/失敗分配給所有檢查點。這樣在繪圖時我就可以獲得分割參考。

非常感謝任何指點。
非常感謝
薩泰傑
下面是一個簡單的腳本,它將通過創建第二個表、操作該表然後將結果帶回原始表來創建新列。雖然這是使用腳本完成的,但腳本中的每個步驟都可以使用 JMP 擅長的交互式點擊方法來執行。
names default to here(1);
// create the example data table
dt = New Table( "Example 3",
Add Rows( 15 ),
New Column( "Rel Interval",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 100, 100, 100, 100, 100] )
),
New Column( "Sr ID",
Character( 8 ),
"Nominal",
Set Values(
{"A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D",
"E"}
)
),
New Column( "Pass_Fail",
Character( 8 ),
"Nominal",
Set Values(
{"Pass", "Pass", "Pass", "Pass", "Pass", "Pass", "Pass", "Pass", "Pass",
"Pass", "Pass", "Fail", "Pass", "Fail", "Pass"}
)
)
);
wait(3); // this is added just so the viewer can see the original data table
// Split the Pass Fail column into 2 columns
dtSplit = dt << Split(
Split By( :Pass_Fail ),
Split( :Pass_Fail ),
Group( :Sr ID ),
Remaining Columns( Drop All ),
Sort by Column Property
);
wait(2);
// Create a new column that has a formula that will set the Pass or Fail value
dtSplit << New Column("Updated Pass_Fail_SrID", character, formula(Word( 1, :Fail || "," || :Pass, "," )));
wait(2);
// convert the formula column into static values
dtSplit:Updated Pass_Fail_SRID << delete formula;
wait(2);
// Delete no longer wanted columns
dtSplit << delete columns("Fail","Pass");
wait(2);
// Update the original data table with the information from the split table
dt << Update(
With( dtSplit ),
Match Columns( :Sr ID = :Sr ID )
);
以下是交互式執行此操作的步驟
- 點擊有Rel Interval、Sr ID、Pass_Fail列的數據表,使該數據表成為當前活動數據表
- 轉到下拉菜單並選擇 Tables==>Split
- 設置Pass_Fail列和“Split By”選項,也設置為“Split Columns”選項,然後設置Sr ID列為“Group”選項
- 點擊確定
- 轉到已創建的新數據表
- 創建一個名為“更新了 Pass_Fail_SrID " 並使其成為數據類型,"Character"
- 右鍵單擊列標題並選擇“公式”
- 在公式窗口中,輸入公式字(1,:失敗||“,”||:通過,“,”)此公式將 Fail 和 Pass 的 2 列連接在一起,並在值之間放置一個逗號。然後它將使用 Word() 函數來選擇串聯列表中的第一個單詞,並且由於沒有 Fails 的行的第一個單詞的值為 Pass,因此結果值將設置正確的值。
- 點擊確定
- 現在轉到新列的列信息對話框窗口,單擊列屬性“公式”,然後單擊刪除。這會將新列中的值轉換為靜態值,而不是計算值。
- 刪除通過和失敗列。他們不再需要。
- 返回原始數據表並轉到下拉菜單並選擇 Tables==Update
- 選擇已在其中創建新列的查找表作為用於從中獲取更新的表
- 選中“匹配列”複選框
- 從兩個數據表中選擇 Sr ID,然後單擊“匹配”按鈕
- 單擊“確定”,您的原始數據表現在將添加新列
嗨,Satej,
最簡單的解決方案是將 Pass_Fail 列重新編碼為 Fail = 0 且 Pass = 1 的連續數字列。 然後你可以通過 Sr ID 查找最小值來確定是否有任何 Sr ID 在任何時候失敗。
請參閱附件中的解決方案
最好的,
TS