Names Default To Here(1);
// Function to recode a selected column
recode_column = Function({dataTable, columnToRecode, newColumnName},
// Check if column exists
If(Column(dataTable, columnToRecode) != {},
// Create a mapping for recoding
aa_recode = Associative Array();
For(i = 1, i <= N Row(dataTable), i++,
aa_recode[Column(dataTable, columnToRecode) << Get Value(i)] = Column(dataTable, columnToRecode) << Get Value(i);
);
dataTable << New Column(newColumnName, Character, Nominal, << Set Each Value(
aa_recode[Column(dataTable, columnToRecode)]
));
cols = {};
For(i = 1, i <= N Col(dataTable), i++,
cols[N Items(cols) + 1] = Column(dataTable, i) << Get Name
);
recodeColListBox << Set Items(cols);
colorColListBox << Set Items(cols); // Refresh heatmap plotting list
Show Message("Column recoded and new column added: " || newColumnName);
,
Show Message("Selected column does not exist.")
);
);
// Function to plot the heatmap
PlotHeatmap = Function({dataTable, colorColumnName},
If(colorColumnName != "",
Graph Builder(
Size(1500, 800),
Show Control Panel(0),
Data Table(dataTable),
Variables(
X(:x_Location),
Y(:y_Location),
Color(Column(dataTable, colorColumnName))
),
Elements(Heatmap(X, Y, Legend(4)))
)
,
Show Message("Please select a column for color.")
)
);
list = {};
For(i = 1, i <= N Table(), i++,
list[i] = Data Table(i) << Get Name
);
// Create the window
win = New Window("JMP ADDIN",
H List Box(
V List Box(
Panel Box("Choose a source data table",
dtListBox = List Box(list, max selected(1))
)
),
Button Box("Get Columns",
chosen = Data Table((dtListBox << Get Selected)[1]);
If(chosen != {},
cols = {};
For(i = 1, i <= N Col(chosen), i++,
cols[N Items(cols) + 1] = Column(chosen, i) << Get Name
);
recodeColListBox << Set Items(cols);
colorColListBox << Set Items(cols); // Refresh for heatmap plotting
,
Show Message("Please select a valid data table.")
);
),
// Panel for selecting columns to recode
V List Box(
Panel Box("Select Columns for Recode",
recodeColListBox = List Box("")
)
),
// Button to recode a column
Button Box("Recode Column",
chosen = Data Table((dtListBox << Get Selected)[1]);
recode_col = recodeColListBox << Get Selected;
If(recode_col != "",
new_col_name = "Recode_" || recode_col; // Define new column name
recode_column(chosen, recode_col, new_col_name);
// Refresh column list after recoding
cols = {};
For(i = 1, i <= N Col(chosen), i++,
cols[N Items(cols) + 1] = Column(chosen, i) << Get Name
);
recodeColListBox << Set Items(cols);
colorColListBox << Set Items(cols); // Ensure the new column is available for heatmap plotting
,
Show Message("Please select a column to recode.")
);
),
// Panel for selecting columns to plot heatmap
V List Box(
Panel Box("Select Columns for Heatmap",
colorColListBox = List Box("")
)
),
// Button to plot the heatmap
Button Box("Plot Heatmap",
selectedColorColumn = colorColListBox << Get Selected;
If(selectedColorColumn != "",
chosen = Data Table((dtListBox << Get Selected)[1]);
If(chosen != {},
PlotHeatmap(chosen, selectedColorColumn);
,
Show Message("Selected data table is invalid.")
);
,
Show Message("Please select a column for color.")
);
)
)
);工作流程:選擇表格-->選擇要重新編碼的列-->重新編碼列(需要協助才能對字元和數字列進行重新編碼)-->刷新列清單-->選擇一列或多列-->繪製熱圖
需要幫助 1)調試當前腳本,我只能在其中重新編碼數字資料類型列
2)如何包含選擇要重新編碼的字元類型列?
3) 我可以以其他方式開啟 jmp(columns--> Recode) 預設的重新編碼使用者介面作為使用者介面的一部分嗎?
這段程式碼看起來像是由某個法學碩士創建的,因此存在許多小錯誤和使用了 JMP 沒有的功能。您能否提供一個範例表,其中還包含正確的結果及其來源的解釋。

這是範例 - 您重新編碼「批次號」以對其進行分組,並使用「重新編碼列」繪製熱圖

範例 2:將測試人員進行分組,然後使用重新編碼的列繪製熱圖
希望有幫助
謝謝
我仍然不確定測試器 3 應該如何變成 2 或您從這兩列中查看哪種類型的熱圖




重新編碼使用的規則是什麼?從您的範例來看,重新編碼似乎只是簡單地採用第1 行和第2 行並對它們進行分組,然後採用第3 行和第4 行並對它們進行分組,依此類推。的值為1,第二個分組的值為2, ETC。
如果是這種情況,重新編碼的列公式很簡單
Ceiling(Row() / 2)
這是您要找的嗎?它適用於字元和數字數據,因為它不依賴 lot_no 或 tester 的值,而僅依賴行號
如果你想讓用戶自由地使用recode平台,這可能並不像你想像的那麼簡單。
我認為你應該重新考慮你的腳本的規格。您必須具備什麼、使用者可以使用 JMP 平台做什麼、他們在使用重新編碼並選擇這些新列後是否可以運行您的腳本…等等
一個列清單就足夠了 - 透過 2 個按鈕,使用者可以決定是否要重新編碼或繪製所選列:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
For Each( {col}, {:age, :height, :weight}, col << Set Modeling Type( "Nominal" ) );
New Window( "simple GUI", << Type("Dialog"),
lb = Filter Col Selector( width( 150 ) ),
Button Box( "recode",
cols = lb << get selected();
dt << select columns( cols );
dt << Recode;
),
Button Box( "plot",
cols = lb << get selected();
If( N Items( cols) >= 2 ,
xcol = cols[1];
ycol = cols[2];
Graph Builder( Variables( X(Eval(xcol) ), Y( Eval(ycol) ) ), Elements( Heatmap( X, Y ) ) );
,
Caption( "select 2 columns" )
);
)
);好的,謝謝..有沒有辦法可以重新編碼一列,然後使用該列繪製圖表?或打開一個新的圖形使用者介面來繪製它?
您能否解釋為什麼要設定一個結合以下兩個步驟的工作流程:
- 重新編碼
- 陰謀
重新編碼是一個非常常見的步驟 - 但在大多數情況下,它是資料管理工作流程的一部分 - 這與資料分析是分開的。為什麼要合併這兩個步驟?
使用者每次繪製列之前是否必須重新編碼?
使用者 A 對列重新編碼後,使用者 B 可以使用重新編碼的資料列,而不必再次重新編碼。或者您是否更喜歡一些「虛擬列」[轉換列],這些列在使用者 A 之後會消失,以便使用者 B 可以定義自己的重新編碼。
你能舉出一個你想要產生的圖的例子嗎?情節總是同一種類型嗎?熱圖?應該繪製哪些欄位?
原始專欄與重新編碼的專欄?一些第三列與重新編碼的列?重新編碼 2 列並繪製它們?