<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 );
當前鍵 = 下一個鍵;
);
顯示(缺陷);