你好
我正在嘗試對列“是否拒絕?”中的值所在的行中的所有資料進行子集化。 ==Y 到名為「rejects」的新表
我嘗試了幾種方法,但都不起作用,並且出現錯誤:
「意外的「Split_dt」。可能缺少「;」或「,」。
第 77 行第 1 列:►Split_dt << 選擇 Where(:is rejection? == "Y" );”
此程式碼是建立列「是否拒絕?」的更大腳本的一部分。
當我運行所有腳本時出現上述錯誤,但當我單獨運行它時它可以正常工作。
我該怎麼做才能修復它?
選項1:
rejects = Split_dt << Subset(
Where(:is rejects? == "Y"),
Output Table Name("rejects"),
All Columns
);
選項2:
Split_dt << Select Where(:is rejects? == "Y");
rejects = Split_dt << Subset(Output Table Name("rejects"), All Columns);
完整腳本:
Split_dt = Current Data Table();
Split_dt << New Column("is rejects?", character, Formula("N"));
Column(Split_dt, "is rejects?") << Delete Formula;
// Get the number of columns in the data table
numCols = N Cols(Split_dt);
// Iterate over each row in the data table
For Each Row(
// Iterate over each column starting from column 6
For(colIndex = 6, colIndex <= numCols, colIndex++,
// Get the column reference
currentCol = Column(Split_dt, colIndex);
// Check if the value in the current cell is greater than 100 and "is rejects?" is "N"
If(
currentCol[] > 100 & :is rejects? == "N" & Contains(currentCol << Get Name, "BI")
== 0,
// Change the value in the "is rejects?" column to "Y"
:is rejects? = "Y";
// Exit the loop early since we only need one match
Break();
);
)
);
rejects = Split_dt << Subset(
Where(:is rejects? == "Y"),
Output Table Name("rejects"),
All Columns
);
我通常在對特定行進行子集設定時使用 Rows()(您也可以對選定的行進行子集設置,但通常這樣做最終會在表中執行不必要的選擇)。
此範例將對 sex ==“F” 的所有行進行子集化
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
rows_to_subset = dt << get rows where(:sex == "F");
dt_subset = dt << Subset(Rows(rows_to_subset), Output Table("Subset F"));感謝您的快速回覆。
您建議的解決方案給了相同的錯誤:(
您使用的是哪個版本的 JMP?您嘗試過我的範例腳本嗎?
嘗試
rejects = Split_dt << Subset(
Filtered Rows(:is rejects? == "Y"),
Output Table Name("rejects"),
All Columns
);