Dear all,

I have a vector generated using the function strptime:

> my.dt
[1] "2004-04-19 08:35:00 W. Europe Daylight Time" "2004-04-19 09:35:00 W.
Europe Daylight Time" "2004-04-19 11:35:00 W. Europe Daylight Time"
[4] "2004-04-19 13:35:00 W. Europe Daylight Time" "2004-04-20 07:50:00 W.
Europe Daylight Time"
> class(my.dt)
[1] "POSIXt"  "POSIXct"

Now I would like to test if the difference from the times to the first time
is lower than a given threshold:
> my.dt - my.dt[1] < threshold

The issue is, I would like to specificy the threshold as flexibly as
possible, and I tried to do this using as.difftime
> as.difftime(23, '%H')
Time difference of 23 hours

However, I cannot specify a threshold larger than 23 hours in units of
hours:
> as.difftime(24, '%H')
Time difference of NA secs

I can hack around this in the following way:
> threshold <- as.difftime(23, '%H')
> threshold
Time difference of 23 hours
> threshold[[1]] <- 47
> threshold
Time difference of 47 hours

In that way I can use my original statement:
>  my.dt - my.dt[1] < threshold
[1] TRUE TRUE TRUE TRUE TRUE

In summary, my question is: Is there a more elegant way than my hack from
above to specify time difference thresholds of for example 47 hours, or of
246 seconds, or of 33 days and 5 hours? This could be using as.difftime or
using other means.

Thanks in advance,
  Lukas

P.S.
> sessionInfo()
R version 2.4.1 (2006-12-18)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"
"base"

other attached packages:
       chron     odfWeave          XML       gplots        gdata
gtools RColorBrewer      lattice      foreign         nlme
     "2.3-9"      "0.7.3"      "1.4-0"      "2.3.2"      "2.3.1"
"2.3.0"      "0.2-3"    "0.14-16"     "0.8-18"     "3.1-79"

	[[alternative HTML version deleted]]

