我有一个 46175*741 矩阵。我想得到每一行的四分位数。基于这个问题(如何创建具有四分位数等级的列?),我尝试了:
dat_quartiles <- apply(t(dat) , 1, function(x) within(x, as.integer(cut(x, quantile(x, probs=0:4/4), include.lowest=TRUE))))
但我得到了错误:
Error in UseMethod("within") : no applicable method for 'within' applied to an object of class "c('integer', 'numeric')"
我到底哪里错了?