[R] quantiles for dates

Dieter Menne dieter.menne at menne-biomed.de
Wed May 14 18:14:32 CEST 2008


GOUACHE David <D.GOUACHE <at> arvalisinstitutduvegetal.fr> writes:

> I was wondering if there is a package in which someone would have 
> created a quantile function that handles vectors of class "Date".

Since dates are just decorated numbers, you can convert in both way.
Written the long way:

dt = rpois(100,100)
class(dt)="Date"
dt
# [1] "1970-03-30" "1970-04-18" "1970-04-08" "1970-04-13" 


# Dates are generated now 
dq= quantile(as.integer(dt))
dq
#   0%    25%    50%    75%   100% 
# 77.00  93.00  98.50 106.25 119.00 
class(dq)="Date"
dq
#         0%          25%          50%          75%         100% 
#"1970-03-19" "1970-04-04" "1970-04-09" "1970-04-17" "1970-04-30" 
 
---
Dieter



More information about the R-help mailing list