嗨,大家好,
我需要獲取收割序列的行數分組數據,例如格式為列的數據:
aaabbbbbccaaadddbbb ...
使用摘要統計信息選項並按此列分組將導致總每個值的出現次數 A B C D (N行):6,8,2,3。我需要的是每組的行數依次分開 :
a,b,c,a,b,d(N行):3,4,2,3,3,3
任何想法?
謝謝,
-院長
我的建議是,使用以下公式創建一個新的公式列:
If( Row() == 1, counter = 0 );
If( Lag( :yourgrouppedcolumnname ) != :yourgrouppedcolumnname,
counter++,
counter
);
counter;
將“ yourgrouppedcolumnnmae”替換為具有重複列的實際列名。
然後,您可以運行摘要平台
表格==>摘要
在新列上,它將為您提供每個分組的計數。
如果需要將結果返回到原始表中,則只需在原始數據表上使用“更新平台”,指向“摘要”表,然後在創建的新列上進行匹配即可。
以下是使用Big Class示例數據表的示例腳本。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
// Create the new binning column based upon the "Sex" column
dt << New Column( "Bin",
formula(
If( Row() == 1, counter = 0 );
If( Lag( :Sex ) != :Sex,
counter++,
counter
);
counter;
)
);
// Calculate the counts of the new binning column
dtSummary = dt << Summary(
Group( :Bin ),
Freq( "None" ),
Weight( "None" ),
Link to original data table( 0 )
);
// Move the counts into the original data table
dt << Update( With( dtSummary ), Match Columns( :Bin = :Bin ) );
