Would this work for you?
if you want to know where the i-th element falls percentage-wise in the
distribution of a vector:
sum(x <= x[i])/length(x)
This could be turned into a function:
pEmpirical <- function(i,x) {
if (length(i) > 1) return(apply(as.matrix(i), 1, pEmpirical,x))
r = sum(x <= x[i])/length(x)
return(r)
}
Michael Weylandt
2011/8/2 ר×××× ××ר×××××¥ <[email protected]>
>
> I'm familiar with the quantile() command, but what if I have a specific
> number that I want to know its location in a vector? I know that in known
> distributions, (for example the normal distribution), there is pnorm and
> qnorm, but how can I do it with unknown vector?
>
>
> thanks in advance
> _________________________________________________________________
>
> Walla! Mail - [1]Get your free unlimited mail today
>
> References
>
> 1. http://www.walla.co.il/
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.