您好JMP社区,
具有一系列整数,范围从0到100。该列始终以0开头,然后从某个行号开始增加。如何删除全为0的行,然后上移非零单元格?我还需要将其应用于同一张纸上的所有列。
示例(“。”表示空单元格)初始数据:
Col-1 Col-2 Col-3
第1行0 0 0
第2行0 0 0
第3行0 0 0
第4行1 0 1
第5行3 1 2
第6行8 4 7
处理后的最终结果:
Col-1 Col-2 Col-3
第1 1 1 1行
第2行3 4 2
第3行8。 7
第4行。 。 。
第5行。 。 。
第6行。 。 。
非常感谢!
史蒂夫
这是一个示例脚本,可将每个独立列的值上移。 使用的示例数据是您提供的数据
Names Default To Here( 1 );
dt = New Table( "Example",
Add Rows( 6 ),
New Column( "Col 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0, 0, 0, 1, 2, 3] )
),
New Column( "Col 2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0, 0, 0, 0, 1, 4] )
),
New Column( "Col 3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [0, 0, 0, 1, 2, 7] )
),
Set Row States( [1, 1, 1, 1, 1, 1] )
);
colNames = dt << get column names( numeric, string );
For( i = 1, i <= N Items( colNames ), i++,
theMatrix = Column( colNames[i] ) << get values;
Column( colNames[i] )[Index( 1, N Rows( dt ) )] = .;
Column( colNames[i] ) << set values( theMatrix[Loc( theMatrix )] );
);