[R] A data selection problem, suggestions highly appreciated

Heywood, Giles Giles.Heywood at CommerzbankIB.com
Thu May 27 09:58:36 CEST 2004


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: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Yong Wang
> Sent: 26 May 2004 20:34
> To: r-help-request at stat.math.ethz.ch
> Cc: r-help at stat.math.ethz.ch
> 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
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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}}




More information about the R-help mailing list