您好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 )] );
);