我想用该点的值和列名称标记我的图表(如在箱形图中)。 目前,我通过将列名与单元格中的值连接起来在 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