[R] choose between dates and times

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue Jul 26 22:19:58 CEST 2005


Kerry Bush <kerryrekky at yahoo.com> writes:

> Dear R-helpers,
>   I have the following data:
> 
>  y    happenat                 x
> 5185 (07/22/05 00:05:14)       14
> 5186 (07/22/05 00:15:14)       14
> 5187 (07/22/05 00:25:14)       14
> 5188 (07/22/05 00:35:14)       14
> ......
> 
> I want to choose between 07/25/05 15:30:00 and
> 07/26/05 12:30:00. Anybody had experience in handling
> this kind of data? Is there a simple way to subset by
> the variable 'happenat'? Thanks.

Simple, perhaps not. This stuff always gets a little heavy, but start
here: 

> strptime("(07/22/05 00:05:14)",format="(%m/%d/%y %H:%M:%S)") >
+     as.POSIXct("2005-07-22 00:06:00")
[1] FALSE
> strptime("(07/22/05 00:05:14)",format="(%m/%d/%y %H:%M:%S)") > 
+     as.POSIXct("2005-07-22 00:05:00")
[1] TRUE

Once you figure out how this works, the rest should follow.

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907




More information about the R-help mailing list