How to calculate the numbers of the observations in quantiles?
问题 Consider I have a million of observations following Gamma distribution with parameters (3,5). I am able to find the quantiles using summary() but I am trying to find how many observations are between each red lines which were divided into 10 pieces? a = rgamma(1e6, shape = 3, rate = 5) summary(a) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.0053 0.3455 0.5351 0.6002 0.7845 4.4458 回答1: We may use cut with table : table(cut(a, quantile(a, 0:10 / 10))) # (0.00202,0.22] (0.22,0.307] (0.307,0.382] (0