On Wed, 12 Jun 2013, Ilya Kipnis <[email protected]> writes:

> For those of you looking to find the last Fridays in a month (quarter,
> etc.), I just wanted to issue a warning about using the timeLastNdayInMonth
> function.  For instance, run these lines:
>
>  #dates<-seq(as.Date("2010-01-01"),as.Date("2013-04-02"),by="day") test case
>   friDates<-dates[which(weekdays(dates)=="Friday")]
>   buggedLastMonthlyFridays<-unique(timeLastNdayInMonth(friDates,5)) #gives
> one week after the last friday of the month
>
> and one will notice that the dates are often at the beginning of the next
> month.  This is my fix:
>
> buggedLastMonthlyFridays[which(as.numeric(substr(buggedLastMonthlyFridays,9,10))<20)]<-
>
> as.Date(buggedLastMonthlyFridays[which(as.numeric(substr(buggedLastMonthlyFridays,9,10))<20)])-7
>
> It's not exactly pretty, but I hope this helps someone out there.
>
> -Ilya Kipnis
>

I suppose the 'timeLastNdayInMonth' function is from a package?  Then you
should also contact directly the package's maintainer.



-- 
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to