cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
lala
Level VIII

如何通过内存数组计算出某列的不重复个数?

我试着用下面的代码可以求出这个结果。

 

请问专家是否有更快捷的方法?

 

谢谢!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

回复: 如何通过内存数组计算出某列的不重复个数?

I use Summarize() to get the unique keys

dt=open("$sample_data\big class.jmp");
summarize( dt, nn = by( column(2)));
rh = n items(nn);
Jim

View solution in original post

4 REPLIES 4
lala
Level VIII

回复: 如何通过内存数组计算出某列的不重复个数?

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
ar = dt << GetAsMatrix( 2 );
nn = Matrix( Associative Array( ar[0, 1] ) << getKeys );
rh = N Row( nn );
peng_liu
Staff

回复: 如何通过内存数组计算出某列的不重复个数?

I often use Summary under Tables to get unique items. The pro is that we have good reasons to believe the underlying implementation is highly optimized. The con is that the approach has to generate a new table, which might be a non-negligible overhead.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
sumdt = dt << Summary(
	Group( :age ),
	Freq( "None" ),
	Weight( "None" )
);
rh = nrow(sumdt);
close(sumdt,nosave);
lala
Level VIII

回复: 如何通过内存数组计算出某列的不重复个数?

感谢专家的帮助。虽然这个答案不是我想要的。

 

txnelson
Super User

回复: 如何通过内存数组计算出某列的不重复个数?

I use Summarize() to get the unique keys

dt=open("$sample_data\big class.jmp");
summarize( dt, nn = by( column(2)));
rh = n items(nn);
Jim