[R] value of nth percentile

Bert Gunter gunter.berton at gene.com
Tue Aug 18 18:41:15 CEST 2009


Inline below.

Bert Gunter
Genentech Nonclinical Biostatisics

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Steve Lianoglou
Sent: Tuesday, August 18, 2009 8:07 AM
To: Ajay Singh
Cc: r-help at r-project.org
Subject: Re: [R] value of nth percentile

Hi Ajay,

On Aug 18, 2009, at 8:16 AM, Ajay Singh wrote:

> Dear All,
> I have to get the value of say 90th percentile of precipitation time  
> series.. The series is of daily precipitation value of 96 years, I  
> have to to get 90the percentile value of daily precipitation each  
> year. If you know the R code or command for this please let me know.
> I would appreciate your early response.

R> dat <- rnorm(100, mean=10, sd=2)
R> quantile(dat, .9)
      90%
12.53047

R> sum(dat < quantile(dat, .9)) / length(dat)
[1] 0.9

-steve

-- Neither of these statements is (strictly) correct. ?quantile will explain
that different algorithms can be used and will give different results:

> dat <- 1:10
> quantile(dat,.8)
80% 
8.2 
> quantile(dat,.8,type=9)
  80% 
8.575 
> quantile(dat,.8,type=4)
80% 
  8 
> sum(dat < quantile(dat,.8,type=9))/10
[1] 0.8
> sum(dat < quantile(dat,.8,type=4))/10
[1] 0.7



--
Steve Lianoglou
Graduate Student: Computational Systems Biology
   |  Memorial Sloan-Kettering Cancer Center
   |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

______________________________________________
R-help at 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.




More information about the R-help mailing list