I have a method which is not so smart --use grep to match the pattern. for example: dates <- c("02/27/92", "02/27/92", "01/14/92", "02/28/92", "02/01/91") day <- as.Date(dates, "%m/%d/%y") day: [1] "1992-02-27" "1992-02-27" "1992-01-14" "1992-02-28" "1991-02-01" If I want to search for 1991, I can use: grep("1991-*", day)
Hope for a better solution. 2013/7/4 Gallon Li <gallon...@gmail.com> > i have converted my data into date format like below: > > > day=as.Date(originaldate,"%m/%d/%Y") > > day[1:5] > [1] "2008-04-12" "2011-07-02" "2011-09-02" "2008-04-12" "2008-04-12" > > I wish to select only those observations from 2007 to 2009, how can I > select from this list? > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > -- ÕÅêÊ Dante.py ÖÐɽ´óѧ09¼¶ÊýѧÓëÓ¦ÓÃÊýѧרҵ ¸öÈËÖ÷Ò³£ºhttp://dantepy.yslsg.org/ [[alternative HTML version deleted]]
______________________________________________ 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.