我想用該點的值和列名稱標記我的圖表(如在箱形圖中)。 目前,我通過將列名與單元格中的值連接起來在 Excel 中執行此操作。 但是,如果我可以在 JMP 中完成,它將為我節省大量時間。
例如我可能有專欄
A B C
1 2 100
1 2 200
2 5 300
我想創建一個新列來描述其他列中的信息:
A = 1 : B = 2 : C = 100
A = 1 : B = 2 : C = 200
A = 2 : B = 5 : C = 300
到目前為止,我已經能夠創建一個包含列名的列表,但無法弄清楚如何迭代和連接其他值。
cdt = 當前數據表();
列名 = {};
這個標籤 = {};
ColNames = cdt << 獲取列名(字符串);
對於(我=3;我<=5;我++)
concat(ThisLabel,ColNames[i]);
// 需要更多工作才能從表中獲取值
先感謝您
這是做你想做的事情的一種方法。我的示例展示了解決問題的硬編碼方法,以及更通用的方法

Names Default To Here( 1 );
// Script to create the required column when the names of the columns are known
dt = New Table( "Example 1",
New Column( "A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 1, 2] ) ),
New Column( "B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2, 2, 5] ) ),
New Column( "C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [100, 200, 300] ) ),
New Column( "D", Character, Nominal, Formula( "A = " || Char( :A ) || ": B = " || Char( :B ) || ": C = " || Char( :C ) ) )
);
// Example where script examines the data table and from it, generates the new column
dt2 = New Table( "Example 2",
New Column( "A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 1, 2] ) ),
New Column( "B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2, 2, 5] ) ),
New Column( "C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [100, 200, 300] ) )
);
colNames = dt2 << get column names( string );
// Build the formula in a string variable
theCMD = "dt2 << New Column( \!"D\!", character, Nominal, formula(";
For Each( {col, index}, colNames,
If( index == 1,
theCMD = theCMD || "\!" " || col,
theCMD = theCMD || "\!" : " || col
);
theCMD = theCMD || " = \!" || Char( :" || col || ") || ";
);
theCMD = theCMD || "));";
Eval( Parse( theCMD ) );如果您確實不需要列名稱,更快的方法是選擇 3 列,然後右鍵單擊其中一個列標題並選擇“新建公式列 -> 字符 -> 用逗號連接”。
或者,如果您確實需要名稱,可以右鍵單擊新的列標題並選擇“公式...”,然後手動編輯公式以包含列標題名稱。它速度較慢,但不需要 JSL 步驟。
請注意,如果所有列都是數字,您可能必須添加一個臨時列(字符列)才能使“字符”選項顯示在“新公式列”列表中。我們希望這在未來的版本中得到簡化: https://community.jmp.com/t5/JMP-Wish-List/Enable-string-concatenation-in-quot-New-Formula-Column-quot-gt/idc-p/582366#M3504