嗨,大家好,
我需要获取收割序列的行数分组数据,例如格式为列的数据:
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 ) );
