Dear All, I have a dataset containing Date column. I need to breakdown this dataset into two parts one which has datapoints before a particular date and the otherone on or after a particular date. for example: "2005-12-15", "2008-12-14", "2012-10-01", "2009-11-15", "2018-10-10", "2014-08-31", "2016-03-27", "2010-01-01". say I want dates before and after "2009-12-31" that means I want ("2005-12-15","2008-12-14","2009-11-15")->x1 and ("2012-10-01","2018-10-10","2014-08-31","2016-03-27","2010-01-01")->x2 I wish to use different programs for these subsets. I could not find any way to compare dates with respect to some date. Moreover dates are random I vary in no. So above is just an example. Any help will be appreciated. regards, GS
this is one way to do it.> x<-as.Date(c("2005/2/10","2002/2/1")) > x[1] "2005-02-10" "2002-02-01"> ind<-x>as.Date("2005/1/1") > x[ind][1] "2005-02-10"> x[!ind][1] "2002-02-01" 2006/1/8, gynmeerut <gynmeerut at indiatimes.com>:> Dear All, > > I have a dataset containing Date column. I need to breakdown this dataset into two parts one which has datapoints before a particular date and the otherone on or after a particular date. > > for example: > "2005-12-15", > "2008-12-14", > "2012-10-01", > "2009-11-15", > "2018-10-10", > "2014-08-31", > "2016-03-27", > "2010-01-01". > say I want dates before and after "2009-12-31" > that means I want ("2005-12-15","2008-12-14","2009-11-15")->x1 > and ("2012-10-01","2018-10-10","2014-08-31","2016-03-27","2010-01-01")->x2 > > > I wish to use different programs for these subsets. > I could not find any way to compare dates with respect to some date. > Moreover dates are random I vary in no. So above is just an example. > > Any help will be appreciated. > > regards, > > GS > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- 伝伷伻佡伖侒 Deparment of Sociology Fudan University
Dear R Users, I am trying to use its, and for that, I need to use as.POSIXct . My dates are of the format:"10 January 2006". How do I convert this into the format acceptable to its ? Thanks, Tolga =============================================================================Please access the attached hyperlink for an important electr...{{dropped}}
See ?strptime Also the help desk article in RNews 4/1 contains info on dates. On 1/11/06, Uzuner, Tolga <tolga.uzuner at csfb.com> wrote:> Dear R Users, > > I am trying to use its, and for that, I need to use as.POSIXct . > > My dates are of the format:"10 January 2006". > > How do I convert this into the format acceptable to its ? > > Thanks, > Tolga > > > > > > > > > > > > =============================================================================> Please access the attached hyperlink for an important electr...{{dropped}} > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >