Re: [R] Week number from a date

2012-02-22 Thread Gabor Grothendieck
On Wed, Feb 22, 2012 at 8:09 AM, arunkumar wrote: > Hi > > My data looks like this > > startDate="2008-06-01" > > dateRange =c( "2008-10-01","2008-12-01") > Is there any method to find the week number from the startDate range > Is the question how many weeks are from the startDate to each of

Re: [R] Week number from a date

2012-02-22 Thread Jan van der Laan
The suggestion below gives you week numbers with week 1 being the week containing the first monday of the year and weeks going from monday to sunday. There are other conventions. The ISO convention is that week 1 is the first week containing at least 4 days in the new year (week 1 of 2012

Re: [R] Week number from a date

2012-02-22 Thread Patrick Breheny
To give a little more detail, you can convert your character strings into POSIX objects, then extract from it virtually anything you would want using strftime. In particular, %W is how you get the week number: > dateRange <- c("2008-10-01","2008-12-01") > x <- as.POSIXlt(dateRange) > strftime(

Re: [R] Week number from a date

2012-02-22 Thread Ingmar Visser
?strptime is a good place to start hth, Ingmar On Wed, Feb 22, 2012 at 2:09 PM, arunkumar wrote: > Hi > > My data looks like this > > startDate="2008-06-01" > > dateRange =c( "2008-10-01","2008-12-01") > Is there any method to find the week number from the startDate range > > - > Thanks