I think I got it, I post it here see if you have better way, please let me
know.

index <- rep(0, length(mydata[,1]))
index[as.Date(mydata3$Date) < as.Date("2006-11-30 23:29:29 PM") &
as.Date(mydata3$Date) > as.Date("2006-09-01 00:00:00 AM")] <- 1
index[as.Date(mydata3$Date) < as.Date("2007-11-30 23:29:29 PM") &
as.Date(mydata3$Date) > as.Date("2007-09-01 00:00:00 AM")] <- 1
index[as.Date(mydata3$Date) < as.Date("2008-11-30 23:29:29 PM") &
as.Date(mydata3$Date) > as.Date("2008-09-01 00:00:00 AM")] <- 1
index[as.Date(mydata3$Date) < as.Date("2009-11-30 23:29:29 PM") &
as.Date(mydata3$Date) > as.Date("2009-09-01 00:00:00 AM")] <- 1
index[as.Date(mydata3$Date) < as.Date("2010-11-30 23:29:29 PM") &
as.Date(mydata3$Date) > as.Date("2010-09-01 00:00:00 AM")] <- 1

Thanks
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Selecting-data-based-on-the-range-of-dates-tp3323452p3323536.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to