重新排序列问题我知道 JMP 按名称降序对列进行排序。 我必须按照测试规范中的显示方式命名我的列,以便更轻松地识别我们所指的测试。 我有 16 个通道 [0 - 15] 和 2 个测试标识符 [ T & R ]。 我在多列中连接不同的数据字段。 下面是一个例子。这种顺序使得在幻灯片中绘制和放置变得很麻烦,因为我们必须移动所有幻灯片。 从示例中您可以看到,它是 0, 1, 10, 11, 12, 13, 14, 15, 2, 3, 4, 5, 6, 7, 8, 9。 有关如何纠正此问题的任何简单建议。 我知道我可以将其设为 00、01、02...使其正确排序,但正如我提到的,我们的规范省略了前导零。
CH0 R 状态 3 @ 频率
CH0 R 状态 4 Delta Amp @ Freq
CH0 T 状态 1 @ 频率
CH1 R 状态 3 @ 频率
CH1 R 状态 4 Delta 放大器@频率
CH1 T 状态 1 @ 频率
CH10 R 状态 3 @ 频率
CH10 R 状态 4 Delta 放大器@频率
CH10 T 状态 1 @ 频率
CH11 R 状态 3 @ 频率
CH11 R 状态 4 Delta 放大器@频率
CH11 T 状态 1 @ 频率
回复:重新排序列问题请标记我作为解决方案发送的最后一条回复。它确实可以帮助其他人将来找到正确的解决方案。
回复:重新排序列问题嗯,多么偶然啊。 我们的 IT 部门正在为我们公司分发 JMP 15。
再次感谢你。回复:重新排序列问题我使用 JMP 15 编写了脚本,它正确评估了
Column( i ) << 获取名称。
然而,在您的回复之后,我回去发现 JMP 14 及更早版本需要 Eval() 来强制 JMP 获取 << get name 的结果
Eval( 列( i ) << 获取名称 )
以下代码适用于 JMP 15 及之前的版本
Names Default To Here( 1 );
dt = New Table( "Example",
Add Rows( 12 ),
New Column( "Column 1", Character, "Nominal" ),
New Column( "CH0 R State 3 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH0 R State 4 Delta Amp @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH0 T State 1 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH1 R State 3 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH1 R State 4 Delta Amp @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH1 T State 1 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH10 R State 3 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH10 R State 4 Delta Amp @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH10 T State 1 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH11 R State 3 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH11 R State 4 Delta Amp @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH11 T State 1 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) )
);
Wait( 5 ); // Wait 5 seconds so one can see the original example table
// If a column name starts with "CH" adjust the name
For( i = 2, i <= N Cols( dt ), i++,
If( Substr( Column( i ) << get name, 1, 2 ) == "CH",
Column( i ) << set property( "Original Name", Eval( Column( i ) << get name ) );
tempName = Substr( Column( i ) << get name, 3 );
number = Word( 1, tempName, " " );
tempName = Substr( tempName, Length( number ) + 2 );
number = Substr( "00", Length( number ) ) || number;
tempName = "CH" || number || " " || tempName;
Column( i ) << set name( tempName );
)
);
// Reorder the table names
dt << reorder by name;
// Replace the column names with the original names
For( i = 1, i <= N Cols( dt ), i++,
If( Is Empty( Column( i ) << get property( "Original Name" ) ) == 0,
Column( i ) << set name( Column( i ) << get property( "Original Name" ) );
Column( i ) << delete property( "Original Name" );
)
);
回复:重新排序列问题谢谢吉姆的帮助... 当您添加前导“0”强制 01 - 10 正确排序时,我明白您在做什么。 脚本中应该将名称更改回原始名称的部分似乎正在运行,但列没有更改。 我进入列信息,列属性显示为“column( i ) << Get Name”,这应该是那个名称还是实际名称? 它删除了列属性但无法重命名该列回复:重新排序列问题下面是一个示例脚本,对于您的示例数据,将数字转换为 3 位数字,按名称对列重新排序,然后将列名称重置回原始名称
Names Default To Here( 1 );
dt = New Table( "Example",
Add Rows( 12 ),
New Column( "Column 1", Character, "Nominal" ),
New Column( "CH0 R State 3 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH0 R State 4 Delta Amp @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH0 T State 1 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH1 R State 3 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH1 R State 4 Delta Amp @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH1 T State 1 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH10 R State 3 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH10 R State 4 Delta Amp @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH10 T State 1 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH11 R State 3 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH11 R State 4 Delta Amp @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH11 T State 1 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) )
);
wait(5); // Wait 5 seconds so one can see the original example table
// If a column name starts with "CH" adjust the name
For( i = 1, i <= N Cols( dt ), i++,
If( Substr( Column( i ) << get name, 1, 2 ) == "CH",
Column( i ) << set property( "Original Name", Column( i ) << get name );
tempName = Substr( Column( i ) << get name, 3 );
number = Word( 1, tempName, " " );
tempName = Substr( tempName, Length( number ) + 2 );
number = Substr( "00", Length( number ) ) || number;
tempName = "CH" || number || " " || tempName;
Column( i ) << set name( tempName );
)
);
// Reorder the table names
dt << reorder by name;
// Replace the column names with the original names
For( i = 1, i <= N Cols( dt ), i++,
If( Is Empty( Column( i ) << get property( "Original Name" ) ) == 0,
Column( i ) << set name( Column( i ) << get property( "Original Name" ) );
Column( i ) << delete property( "Original Name" );
)
);
回复:重新排序列问题我正在尝试处理您所描述的内容,但我无法弄清楚。 您能举个例子吗?
谢谢回复:重新排序列问题你让我很困惑。 如果我理解正确,您想按字母顺序对列重新排序,但列名称中有非零填充的数字。 所以我认为你的问题是,如何正确地重新排序列,就好像数字被零填充一样。 这与数据表中有多少行无关。 所以我上面的建议应该仍然成立。 读入数据表后,您可以创建一个小脚本,将原始名称保存到新的列属性中,将列名称更改为零填充名称,对列重新排序,然后再次循环遍历列,更改名称回到原来的列名。
这将运行得非常快,因为它不会更改任何数据,只会更改列名称。
我缺少什么?回复:重新排序列问题谢谢吉姆..
我忘了提及我在 SQL 脚本中创建了此列。 考虑到我带来了大约 200 万行数据,我尝试在表实际到达 JMP 之前尽可能多地执行操作以节省时间。 所以列将是原始列。回复:重新排序列问题我已经处理了这个问题,通过一个脚本将名称更改为我需要的形式,然后我可以使用“按名称重新排序”。我首先在脚本中创建一个名为“原始名称”的列属性,以便我随时可以将名称改回来。一旦脚本对名称进行了更改,它就可以发出
dt << 按名称重新排序
之后,您可以重新循环列名称并从“原始名称”列属性中获取值,并将列名称设置回原始名称。