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]]

______________________________________________
[email protected] 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.

______________________________________________
[email protected] 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.

Reply via email to