大家好
我有“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() 函数选择连接列表中的第一个单词,并且由于没有失败的行的第一个单词将具有 Pass 值,因此结果值将设置正确的值。
- 点击确定
- 现在转到新列的 Col Info 对话框窗口并单击列属性“公式”,然后单击“删除”。这会将新列中的值转换为静态值,而不是计算值。
- 删除通过和失败列。不再需要它们。
- 回到原来的数据表,进入下拉菜单,选择Tables==Update
- 选择已在其中创建新列的查找表作为用于从中获取更新的表
- 选中“匹配列”复选框
- 从两个数据表中选择 Sr ID,然后单击匹配按钮
- 单击确定,您的原始数据表现在将添加新列
嗨,萨特杰,
最简单的解决方案是将您的 Pass_Fail 列重新编码为连续数值列,其中 Fail = 0 和 Pass = 1。 然后,您可以通过 Sr ID 查找最小值,以确定是否有任何 Sr ID 在任何时候失败。
请参阅随附的此解决方案
最好的,
TS