[R] date from weeknumber
David Winsemius
dwinsemius at comcast.net
Wed Jul 21 04:56:57 CEST 2010
On Jul 20, 2010, at 6:37 PM, H Rao wrote:
> Hi,
>
> Is there a function to get the last(or first) day of the week, given
> the
> week number of the year?
>
> For eg, week number for 7/20 is 29 as obtained by
> format(Sys.Date(),"%U"),
> is there a function which returns 7/25 - the last day of week # 29
>
require(tis)
nthMon <- function(x) as.Date(currentMonday(xTi=as.Date("2010-01-01"))
+7*(x-1))
> nthMon(2)
[1] "2010-01-11"
Or:
nthMonYr <- function(n, Yr)
as.Date(currentMonday(xTi=as.Date(paste(Yr,"-01-01",sep="")))+7*(n-1))
> nthMonYr(2,2010)
[1] "2010-01-11"
> TIA,
> Rao.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list