It does not seem to work for me. I will show you exactly my data format SMA$TIME_DATE "28/9/2014" "17/6/2014" "19/9/2014" "17/1/2015" "13/1/2015" "21/10/2014"
Shipment$DateRequire "2014-06-09" "2014-06-16" "2014-06-16" "2014-06-16" "2014-06-17" "2014-06-23" What I would like to do is the cut the first set of dates into the second set of dates > From: drjimle...@gmail.com > Date: Fri, 3 Jun 2016 18:59:11 +1000 > Subject: Re: [R] Cut Dates into bins > To: teotj...@hotmail.com > CC: r-help@r-project.org > > Hi Tjun Kiat, > This seems to work: > > daily_date<-as.Date(paste("2000-01",1:28,sep="-"),"%Y-%m-%d") > weekly_date<-as.Date(paste(c(1,8,15,22,28),"01/2000",sep="/"), > "%d/%m/%Y") > cut(daily_date,breaks=weekly_date,include.lowest=TRUE, > labels=paste("Week",1:4)) > > Jim > > > On Fri, Jun 3, 2016 at 6:00 PM, TJUN KIAT TEO <teotj...@hotmail.com> wrote: > > I have two set of dates > > > > 2000-01-01 > > > > 01/01/2000 > > > > The second one occurs weekly and the first one occurs in daily. I would > > like to bin the first set of dates into the second set of dates. What is > > the best way to do it? > > > > I tried converting both formats into numeric formats > > > > DateBase=sort(as.numeric(as.POSIXlt(unique(Shipment$DateRequire),format="%Y-%m-%D",origin="1900-01-01"))) > > > > Compare=as.numeric(as.POSIXlt(SMA$TIME_DATE,format="%d/%m/%y",origin="01/01/1900")) > > > > But the numeric numbers turned out to be very different. > > > > Tjun Kiat > > > > > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.