Get quantile for each value

我的未来我决定 提交于 2020-01-24 17:40:11

问题


Is there an implemented (!) function in R which gives you the empirical quantile for each value? I couldn't find any ...

Let's say we have x

x = c(1,3,4,2)

I want to have the quantile of each element.

[1] 0.25, 0.75, 1, 0.5 

Thank you very much!


回答1:


You can use the ecdf() function:

ecdf(x)(x)
[1] 0.25 0.75 1.00 0.50

ecdf(x) creates a function, and you pass the elements of x to that function. The syntax admittedly looks strange



来源:https://stackoverflow.com/questions/50842640/get-quantile-for-each-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!