 
Please help to solve that problem:
 
filter and merge 2 big Df's  by=t_chr in sec.
 
 
 require(zoo)
  t1="2012-03-25 17:00:00.0"
  t2="2012-03-25 17:00:05.0"  
  t1_POSIXlt<-strptime(t1, "%Y-%m-%d %H:%M:%OS")#
  t2_POSIXlt<-strptime(t2, "%Y-%m-%d %H:%M:%OS")#
#  ts_t1t2_POSIXlt<-seq(t1_POSIXlt,t2_POSIXlt,length.out =-1+2*length(seq(t1_POSIXlt,t2_POSIXlt, "sec") ) )
  ts_t1t2_POSIXlt<-seq(t1_POSIXlt,t2_POSIXlt,length.out =length(seq(t1_POSIXlt,t2_POSIXlt, "sec") ) )
  t_ts_t1t2_chr<-as.character(format(ts_t1t2_POSIXlt,"%Y-%m-%d %H:%M:%OS"))
  tail(t_ts_t1t2_chr)
  t_chr<-rep(t_ts_t1t2_chr,c((1:(-1+length(t_ts_t1t2_chr))),1))
  str(t_chr)
# system.time()
Df.a<-as.data.frame(cbind(t_chr,a=c(1:length(t_chr)),b=2*c(1:length(t_chr)),c=0.1*c(length(t_chr):1))); Df.a
 
 
#----------------------------------------
#We wants to obtain" for each single second (time as a key) a) mean filtered
                 t_chr  a       b     c
  2012-03-25 17:00:00  1       2     1.6
  2012-03-25 17:00:01  2.5     5     1.45
  2012-03-25 17:00:02  5       10    1.2
  2012-03-25 17:00:03  8.5     17    0.85
  2012-03-25 17:00:04 13       26 0  0.4
  2012-03-25 17:00:05 16       32    0.1

Df.a.filtered.mean=??? 
#------------------------------------------
#We wants to obtain" for each single second (time as a key) 
b) max filtered
#key = time, each second: 1 max from these same seconds
                 t_chr  a  b   c
1  2012-03-25 17:00:00  1  2 1.6
3  2012-03-25 17:00:01  3  6 1.5
6  2012-03-25 17:00:02  6 12 1.3
10 2012-03-25 17:00:03 10 20 1.0
10 2012-03-25 17:00:04 15 30 1.0
16 2012-03-25 17:00:05 16 32 0.1

Df.a.filtered.max =??? 
 
 
#------------------------------------------
 
the problem is, taht we have huge matrix. The solution should be fast.
 
next we want to merge it with another Data frame
#------------------------------------------
  t1="2012-03-25 17:00:00.0"
  t2="2012-03-25 17:00:05.0"  
  t1_POSIXlt<-strptime(t1, "%Y-%m-%d %H:%M:%OS")#
  t2_POSIXlt<-strptime(t2, "%Y-%m-%d %H:%M:%OS")#
  ts_t1t2_POSIXlt<-seq(t1_POSIXlt,t2_POSIXlt,length.out =-1+2*length(seq(t1_POSIXlt,t2_POSIXlt, "sec") ) )
#  ts_t1t2_POSIXlt<-seq(t1_POSIXlt,t2_POSIXlt,length.out =length(seq(t1_POSIXlt,t2_POSIXlt, "sec") ) )
  t_chr2<-t_ts_t1t2_chr<-as.character(format(ts_t1t2_POSIXlt,"%Y-%m-%d %H:%M:%OS"))
  tail(t_ts_t1t2_chr)
Df.b<-as.data.frame(cbind(t_chr2,dfb.b1=c(1:length(t_chr2)),dfb.b=2*c(1:length(t_chr2)),dfb.c=0.1*c(length(t_chr2):1))); Df.b
#------------------------------------------
 
merge(Df.a,Df.b, by.x=t_chr,by.y=t_chr2,all.x=TRUE,all.y=TRUE)
 
And if in Df.a there is no all seconds measurements?
And if in Df.a. there are many NA?   
How we can handle it in R?
 
Thanks
 
KaluzaEA.
 
 

	[[alternative HTML version deleted]]

