如果我有一個名為 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