First convert your dates to POSIXct, similar to the following:
tmp <- strptime("Jan1 18:56:24",format="%b%d %H:%M:%S")
[Here is a synthetic example for demo purposes]
tmp <- seq.POSIXt(from=Sys.time(),length=100,by=1)
Then assign observations to 5s periods, and detect changes in these:
a5secperiod <- floor(as.numeric(tmp)/5)
lastinperiod <- tmp[which(diff(c(a5secperiod[1],a5secperiod))!=0)-1]
You may find it convenient to use the class 'its' in package 'its' (on CRAN)
to store the data and POSIX dates in a single object.
- Giles
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Yong Wang
> Sent: 26 May 2004 20:34
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: [R] A data selection problem, suggestions highly appreciated
>
>
> Hi, All
> I get following question:
> A data format like following:
>
> [Day time x y]
>
> Jan1 18:56:24 x1 y1
> Jan1 18:56:25 x2 y2
> Jan1 18:56:27 x3 y3
> Jan1 18:56:28 x4 y4
> Jan1 18:56:31 x5 y5
> .....................
> .....................
>
> what I wanna do is to partion the time interval by unit of 5 seconds.
> and pick x,y corresponding to the last time within that
> interval. for the
> example above,
> suppose 18:56:24 is the starting time, the time included in
> the interval
> will be up to 18:56:28, therefore I want to get x4 and y4,
> and store them
> somewhere else.
> you might know this is the so called high frequency data. can
> you let me
> know how to do this partion and pick in R or Splus.
> suggestions are really and hihgly appreciated.
>
> thank you very much.
> best regards
> yong
>
> ______________________________________________
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
**********************************************************************
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html