[R] Percentiles in R
Jose Luis Aznarte M.
jlaznarte at decsai.ugr.es
Tue Sep 11 19:09:24 CEST 2007
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
> x
[1] "-0,39559" "1,1916" "0,23214" "1,656" "-0,3439" "-0,50568"
[7] "0,52281" "0,96209" "0,0087242" "-0,030727" "1,0935" "0,35159"
[13] "0,79229" "0,81791" "0,3186" "1,0165" "0,65567" "-0,56474"
[19] "-0,34662" "0,70435" "-0,73285" "-0,60452" "-0,92526" "-0,296"
[25] "0,51298" "0,38654" "0,32469" "-0,92555" "0,53023" "0,050059"
[31] "1,09" "-0,35462" "0,37674" "1,1409" "0,072098" "1,4234"
[37] "1,43" "0,68532" "0,078089" "0,61944"
and, if I want to see the 10th percentile, in Matlab I go
>> prctile(x, 10)
ans =
-0.4067
But in R:
> quantile(x, probs=.1)
10%
51.5
I need to obtain -0.4067, do you see what I mean? Thanks a lot again!!
Jose Luis Aznarte M. escribió:
> Hi there! Still struggling to translate Matlab code into R's tsDyn package.
> Here is my question: Is there in R an equivalent function to Matlab's
> prctile()? To the moment I thought it was quantile(), but I just
> realized I was wrong. The definition of the Matlab function:
>
> prctile
> Percentiles of a sample
> SyntaxY = prctile(X,p)
> Description
> Y = prctile(X,p) calculates a value that is greater than p percent of
> the values in X. The values of p must lie in the interval [0 100]. For
> instance, if p = 50 then Y is the median of X
>
> Thanks!!
>
>
--
-- --
Jose Luis Aznarte M. http://decsai.ugr.es/~jlaznarte
Department of Computer Science and Artificial Intelligence
Universidad de Granada Tel. +34 - 958 - 24 04 67
GRANADA (Spain) Fax: +34 - 958 - 24 00 79
More information about the R-help
mailing list