Skip to content
Prev 325351 / 398503 Next

identify data points by certain criteria

Hi,
May be this helps:
source("Ye_data.txt")
?dim(dat1)
#[1] 44640???? 3
library(xts)
?xt1<- xts(dat1[,-1],strptime(dat1[,1],"%m/%d/%Y %H:%M"))
xtSub<-xt1["T00:00:00/T08:00:00"]
?dim(xt1)
#[1] 44640???? 2
?dim(xtSub)
#[1] 14911???? 2
lst1<-split(xtSub,as.Date(index(xtSub)))

sapply(lst1,function(x) {indx<- which(rowSums(x)==0);indx1<-which.max(c(1,diff(index(x)[indx]))) })
#2012-12-01 2012-12-02 2012-12-03 2012-12-04 2012-12-05 2012-12-06 2012-12-07 
#?????? 373???????? 41??????? 262??????? 268??????? 266??????? 254??????? 274 
#2012-12-08 2012-12-09 2012-12-10 2012-12-11 2012-12-12 2012-12-13 2012-12-14 
#?????? 109????????? 1??????? 323??????? 264??????? 279??????? 353??????? 265 
#2012-12-15 2012-12-16 2012-12-17 2012-12-18 2012-12-19 2012-12-20 2012-12-21 
#?????? 327??????? 226??????? 264??????? 269??????? 271??????? 267??????? 276 
#2012-12-22 2012-12-23 2012-12-24 2012-12-25 2012-12-26 2012-12-27 2012-12-28 
#?????? 360??????? 162??????? 222???????? 81??????? 231??????? 143??????? 364 
#2012-12-29 2012-12-30 2012-12-31 
?#????? 122??????? 399??????? 418 
?lst2<-lapply(lst1,function(x) {indx<- which(rowSums(x)==0);indx1<-which.max(c(1,diff(index(x)[indx])));index(x)[indx1] })

lst2[1:3]
#$`2012-12-01`
#[1] "2012-12-01 06:12:00 EST"
#
#$`2012-12-02`
#[1] "2012-12-02 00:40:00 EST"
#
#$`2012-12-03`
#[1] "2012-12-03 04:21:00 EST"
A.K.
Message-ID: <1371154524.46060.YahooMailNeo@web142602.mail.bf1.yahoo.com>
In-Reply-To: <CAAvu=bmUYmWLobPnQR==VQQwwnip_Ct+JVd5kpR7URe+1Oj=gQ@mail.gmail.com>