Hi,

I am trying to count weekday of the month using R. For example, 1/4/2001
is the 4th weekday of Jan, and 1/5/2001 is the 5th weekday of the month, and
1/8/2001 is the 6th weekday of the month, etc. I get as far as extracting
the weekdays from a sequence of dates (see below). But I have not yet
figured out a fast way of counting without using a For Loop. Does anyone
know how to do such counting efficiently in R?

Thanks!

library(chron)
dts=seq(dates("1/4/01"),dates("3/31/01"),1)
wkday=dts[!is.weekend(dts)]
weekdays(wkday)
 [1] Thu Fri Mon Tue Wed Thu Fri Mon Tue Wed Thu Fri Mon Tue Wed Thu Fri Mon
Tue Wed
[21] Thu Fri Mon Tue Wed Thu Fri Mon Tue Wed Thu Fri Mon Tue Wed Thu Fri Mon
Tue Wed
[41] Thu Fri Mon Tue Wed Thu Fri Mon Tue Wed Thu Fri Mon Tue Wed Thu Fri Mon
Tue Wed
[61] Thu Fri
Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat



-- 
Tom

	[[alternative HTML version deleted]]

