<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />我想从列值创建一个关联数组。我很好奇 JMP 社区中是否有人有聪明的解决方案。我正在使用 JMP10。下面是一个例子。
// 对于以下数据表:
example = 新表( "示例数据", 添加行( 27 ), 新列( "批次", 字符, 名义值, 设置值(
{“A”,“A”,“A”,“A”,“A”,“A”,“A”,“A”,“A”,“B”,“B”,“B”,“ B”、“B”、“B”、“B”、“B”、“B”、“C”、“C”、“C”、“C”、“C”、“C”、“C” 、“C”、“C”}
) ), 新列(“测试”, 字符, 标称值, 设置值(
{“测试1”,“测试1”,“测试1”,“测试2”,“测试2”,“测试2”,“测试3”,“测试3”,“测试3”,“测试1”,“测试1”,“测试1”,“测试2”,“测试2”,“测试2”,
“测试3”,“测试3”,“测试3”,“测试1”,“测试1”,“测试1”,“测试2”,“测试2”,“测试2”,“测试3”,“测试3”,“测试3”}
) ), New Column( "参数", 字符, 标称值, 设定值(
{“参数1”,“参数2”,“参数3”,“参数1”,“参数2”,“参数3”,“参数1”,“参数2”,“参数3”,“参数1”,“参数2”,“参数3”,“参数1",
“参数2”、“参数3”、“参数1”、“参数2”、“参数3”、“参数1”、“参数2”、“参数3”、“参数1”、“参数2”、“参数3”、“参数1”、“参数2” “,
"Param3"} ) ), 新列( "产量", 数字, 连续, 格式( "", 16 ),
设置值( [1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0])
), New Column( "缺陷代码", 字符, 标称值, 公式( If( :Yield == 0, :Test || "_" || :Parameter ) ) ) );
// 我想创建一个关联数组,其中 key = Lot,value = Defect Codes。请参阅下面的示例。
// 编写此脚本的最佳方法是什么?
// 作为奖励,是否可以创建具有多个级别的关联数组(即:批次 => 测试 => 参数 => 缺陷代码)?
缺陷=关联数组(例如:批次);
缺陷["A"] = {"Test1_Param3", "Test2_Param2", "Test2_Param3", "Test3_Param2"};
缺陷[“B”] = {“Test1_Param1”,“Test1_Param2”,“Test1_Param3”,“Test2_Param2”,“Test3_Param2”,“Test3_Param3”};
缺陷["C"] = {"Test1_Param2", "Test1_Param3", "Test2_Param3", "Test3_Param3"};
// 谢谢您的帮助!
如果有人好奇:
缺陷=关联数组(:Lot);
currentkey1 = 缺陷 << 第一个;
For( i = 1, i <= N 项( 缺陷 ), i++,
value1 = 关联数组( :Test[example << 获取行Where( :Lot == currentkey1 )] );
缺陷[当前键1] = 值1;
currentkey2 = 缺陷[currentkey1] << 第一;
For( j = 1, j <= N 项( 缺陷[当前key1] ), j++,
value2 = :缺陷代码[示例 << Get RowsWhere(:Lot == currentkey1 & :Test == currentkey2 & :Yield == 0 )];
缺陷[当前键1][当前键2] = 值2;
nextkey2 = 缺陷[currentkey1] << Next( currentkey2 );
当前键2 = 下一个键2;
);
nextkey1 = 缺陷 << Next( currentkey1 );
当前键1 = 下一个键1;
);
显示(缺陷);
我想出了如何创建一个关联数组,其中键 = 批次,值 = 缺陷代码。
我很好奇是否有关于多级关联数组的建议。谢谢!
缺陷=关联数组(例如:批次);
currentkey = 缺陷 << 第一;
For( i = 1, i <= N 项( 缺陷 ), i++,
值 = :缺陷代码[示例 << Get RowsWhere( :Lot == currentkey & :Yield == 0 )];
缺陷[当前键] = 值;
nextkey = 缺陷 << Next( currentkey );
当前键 = 下一个键;
);
显示(缺陷);