如果我有一个名为 X 的列,其中包含 100 个值,它是 {1-100} 的序列,并且我想检索 10 个最小值,我知道我可以使用以下命令:
dt = current data table();
temp1 = dt:X << get values;
temp2 = quantile(0.1,temp1);
dt << get rows where(:X<TEMP2></TEMP2>
假设我用缺失值替换 10 个最大值(即 91-100),有没有办法获得相同的 10 个最小值? 我相信分位数函数不会考虑缺失值。
感谢您的帮助
你自己看。
Names Default to Here( 1 );
dt = New Table( "Untitled 2",
Add Rows( 10 ),
New Column( "Full",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] )
),
New Column( "Partial",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 2, 3, 4, 5, 6, 7, ., ., .] )
)
);
values = :full << Get As Matrix;
Show( Quantile( 0.1, values ) );
values = :Partial << Get As Matrix;
Show( Quantile( 0.1, values ) );
缺失值的存在会改变样本分位数,因此它肯定会改变所选的行。
您想获取行或值吗? 下面是一个如何获得 10 个最小非缺失值的示例
temp1 = Sort Ascending(dt:X << get values); //get values in column Value
temp1 = temp1[Loc(temp1)]; //ignore missing
tensmallest = temp1[1::10]; //get 10 first values in list