On Wed, Mar 03, 2004 at 06:58:02AM -0500, Gabor Grothendieck wrote: > > Here are three different ways (using x as defined in your > post): > > with( month.day.year(x), day.of.week(month,day,year) ) > > do.call( "day.of.week", month.day.year(x) ) > > as.numeric(x-3)%%7 # uses fact that chron(3) is Sunday
Thanks! Using this, I wrote -- library(chron); prevFriday <- function(x) { repeat { x <- x - 1; if (5 == with(month.day.year(x), day.of.week(month,day,year))) break; } return(x); } x = dates("12-02-04", format="d-m-y") print(prevFriday(x)) and it works. :-) Could someone give me a glimmer into HOW and WHY that expression with(month.day.year(x), day.of.week(month,day,year)) works? :-) -- Ajay Shah Consultant [EMAIL PROTECTED] Department of Economic Affairs http://www.mayin.org/ajayshah Ministry of Finance, New Delhi ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html