On Tue, Sep 11, 2007 at 07:09:24PM +0200, Jose Luis Aznarte M. wrote:
>     Thank you all! But the problem is that quantile() returns "how many 
> data" are greater than p percent, and not a value in the domain of the 
> vector under scrutiny. For example, I have a vector

not quite, quantile returns an estimate of the p-th percentile point
of the data. You're correct, it doesn't return an element of the data,
because it linearly interpolates between data points.

1) Do you REALLY need an element of the data set, or is the linear
interpolation, which should be more accurate, ok for your purposes?
For example, what would you want from quantile(c(1,2),.5)? Quantile
will return 1.5 in this case, what would your matlab function do? a
similar thing occurs when you want quantile(c(1,2,3,4,5),.1295), there
is no exactly .1295 quantile in this dataset so quantile interpolates
and returns 1.518 

2) If you need an element of the data set, you could simply do
something like

(sort(x))[round(NROW(x) * p)]



-- 
Daniel Lakeland
[EMAIL PROTECTED]
http://www.street-artists.org/~dlakelan

______________________________________________
R-help@r-project.org 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.

Reply via email to