2
我想刪除高於97.5%且低於2.5%的數據點。我創建了以下吝嗇的數據集來解釋這個問題:刪除特定分位數以外的數據點
y <- data.table(a = rep(c("b","d"), each = 2, times = 3), c=rep(c("e","f"),
each = 3, times = 2), seq(1,6))
我創建了下面的腳本來完成這個任務:
require(data.table)
y[, trimErr := ifelse(y$V3 < quantile(y$V3, 0.95) & y$V3 > quantile(y$V3, 0.05),y$V3, NA),
by = list(a,c)]
然後我得到了4個警告信息,我將只提供第一個警告:
Warning messages:
1: In `[.data.table`(y, , `:=`(trimErr, ifelse(y$V3 < quantile(y$V3, :
RHS 1 is length 12 (greater than the size (3) of group 1). The last 9 element(s) will be discarded.
請問你能向我解釋一下警告的含義以及如何修改我的代碼。
你會建議一個更好的代碼來刪除頂部和底部2.5%的數據。提前致謝。
謝謝GSEE內
y$
,做得好 –