[R] number of days

Bill.Venables at csiro.au Bill.Venables at csiro.au
Mon May 14 12:29:21 CEST 2007

The standard answer is to use

> as.POSIXlt("2007-05-14") - as.POSIXlt("1950-01-01")
Time difference of 20952 days

If you want to ensure the time difference is in daily units, then
> difftime(as.POSIXlt("2007-05-14"), 
	      as.POSIXlt("1950-01-01"), units = "days")
Time difference of 20952 days

If you want to use the answer in numerical computations, then one more
coercion is usually needed

> as.numeric(difftime(as.POSIXlt("2007-05-14"), 
				   as.POSIXlt("1950-01-01"), units =
[1] 20952 

Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
Office Phone (email preferred):   +61 7 3826 7251
Fax (if absolutely necessary):    +61 7 3826 7304
Mobile:                        (I don't have one!)
Home Phone:                       +61 7 3286 7700
mailto:Bill.Venables at csiro.au

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of threshold
Sent: Monday, 14 May 2007 7:16 PM
To: r-help at stat.math.ethz.ch
Subject: [R] number of days

Hi, some of you knows how to calculate in R the number of days between
issue relevant in option pricing
thanks, robert
View this message in context:
Sent from the R help mailing list archive at Nabble.com.

R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list