【问题标题】:How to calculate percentile.exe in R like we do in MS excel如何像我们在 MS excel 中一样计算 R 中的 percentile.exe
【发布时间】:2019-12-08 02:25:11
【问题描述】:

如何计算r中的percentile.exc

我有一些零售数据,我需要根据 Order_ID 和 Product ID 计算百分位数(第 25 位和第 75 位)、平均中位数和计数。使用 Excel 计算平均值和中位数检查结果是否正确,但我的百分位值不匹配。

25th Perc-13087.5、Average-24313.51667、Median-20167、75th Perc-38916.25

     pivot_MRP <- Test %>% group_by(Product_Code) %>% 
                summarise(MRP_25 = quantile(MRP,0.25), 
                          MRP_Median = median(MRP),
                          MRP_1_Avg = mean(MRP), 
                          MRP_75 = quantile(MRP, 0.75),
                          MRP_count = n())

        pivot_Disc <- Test %>% group_by(Order_ID) %>% 
            summarise(MRP_25 = quantile(MRP,0.25), 
                      MRP_Median = median(MRP),
                      MRP_1_Avg = mean(MRP), 
                      MRP_75 = quantile(MRP, 0.75),
                      MRP_count = n())

【问题讨论】:

  • percentile.exe 是做什么的?是什么程序吗?
  • @NelsonGon 我很确定他的意思是 percentile.exc 函数,它是 Excel 中的函数。

标签: r excel


【解决方案1】:

使用quantile 函数。

data<-c(1,1,2,2,3,3) #Your data
quantile(data,c(0,0.25,0.5,0.75)) # Data and a vector of probabilities

那么你就有了。

  0%   25%   50%  75% 
  1.00 1.25 2.00 2.75 

【讨论】:

  • 谢谢罗德里戈....但这不符合我的目的....我正在寻找 percentile.exe 方法...您在 percentile.inc 中提出的建议...跨度>
【解决方案2】:

感谢您的回答。

我弄清楚了自己并找到了答案。

                summarise(MRP_25 = quantile(MRP,0.25, type=6), 
                          MRP_Median = median(MRP),
                          MRP_1_Avg = mean(MRP), 
                          MRP_75 = quantile(MRP, 0.75, type=6),
                          MRP_count = n())'''

all we need add is 'type=6' in quantile

Thanks you all :)

【讨论】:

    猜你喜欢
    • 2014-03-28
    • 1970-01-01
    • 2023-03-09
    • 2014-07-06
    • 2019-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-26
    相关资源
    最近更新 更多