[R] Calculating Percentile in R

ecatchpole e.catchpole at adfa.edu.au
Mon Jun 18 09:06:29 CEST 2007


Quantiles aren't uniquely defined. Type

?quantile

to learn more about the various possibilities built in to R.

Ted.

Megh Dal wrote on 06/18/2007 04:37 PM:
> Hi all,
>  
> I have a problem on how R calculates Percentiles :
>  
> Suppose I have following data set:
>   
>> data1
>>     
>   [1] -16648185 -14463457 -14449400 -13905309 -13443436 -13234755 -12956282 -11660896
>   [9] -10061040  -9805005  -9789583  -9754642  -9562164  -9391709  -9212182  -9151073
>  [17]  -9092732  -9068214  -8978151  -8943912  -8761890  -8632106  -8541580  -8501249
>  [25]  -8234466  -8219015  -8193543  -7488279  -7340768  -7236684  -7225458  -7159465
>  [33]  -6819625  -6810858  -6755620  -6626439  -6610901  -6551762  -6207377  -6192583
>  [41]  -6106783  -6077051  -6035300  -6035195  -6019017  -5954375  -5946285  -5886082
>  [49]  -5880402  -5723368  -5668698  -5599168  -5548276  -5445734  -5412312  -5384707
>  [57]  -5309365  -5303425  -5285274  -5204585  -5096301  -5092182  -5053349  -5041533
>  [65]  -5021234  -5005402  -4984232  -4981990  -4964457  -4936653  -4920384  -4918021
>  [73]  -4895351  -4843258  -4824730  -4774792  -4771018  -4616156  -4590430  -4444262
>  [81]  -4443954  -4435397  -4415112  -4374465  -4341858  -4267891  -4252410  -4185021
>  [89]  -4164458  -4158863  -4020436  -4006030  -3975819  -3959667  -3916414  -3876878
>  [97]  -3765340  -3729338  -3713670  -3634991
>
> Now the 5th percentile should be value corresponding to 0.05*(100+1) = 5.05 = 5 (rounded)
>  
> hence : -13443436 
>  
> But R give the value :
>   
>> quantile(data1, 0.05)
>>     
>        5% 
> -13245189 
>  
> Can anyone clarify me on this regards?
>  
> Thanks
> Megh
>
>
>        
> ____________________________________________________________________________________
>
> Comedy with an Edge to see what's on, when. 
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>   


-- 
 Dr E.A. Catchpole  
 Visiting Fellow
 Univ of New South Wales at ADFA, Canberra, Australia
    _	  and University of Kent, Canterbury, England
   'v'	  - www.pems.adfa.edu.au/~ecatchpole          
  /   \	  - fax: +61 2 6268 8786		   
   m m    - ph:  +61 2 6268 8895



More information about the R-help mailing list