Re: [R] Selecting data based on the range of dates

2011-02-25 Thread Rob Tirrell
Try my.date <- strptime("20/2/06 11:16:16.683", "%d/%m/%y %H:%M:%OS") Then you can examine my.date$mon. -- Robert Tirrell | r...@stanford.edu | (607) 437-6532 Program in Biomedical Informatics | Butte Lab | Stanford University On Thu, Feb 24, 2011 at 14:12, Belle wrote: > > I think I got it,

Re: [R] Selecting data based on the range of dates

2011-02-25 Thread Belle
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

[R] Selecting data based on the range of dates

2011-02-25 Thread Belle
Hi: I want to give an index with all the dates between Sept. to Nov. as 1, and anything else is 0. It doesn't matter which year it is, as long as it is between Sept. to Nov, then set up to 1, otherwise is 0. My data frame looks like below: ID Date 201 1/1/05 6:07 AM 201 3/27/09 9:4