[R] number of Mondays

David Winsemius dwinsemius at comcast.net
Thu Jan 15 20:50:42 CET 2009


On Jan 15, 2009, at 2:28 PM, Carlos Hernandez wrote:

> dear All,
> i'm trying to calculate the number of Mondays, Tuesdays, etc that  
> each month within a date range has. I have time series data that  
> spans 60 months and i want to calculate the number of Mondays,  
> Tuesdays, Wed, etc of each month. (I want to control for weekly  
> seasonality but my data is monthly).
>
> Is there an easy way to to this in R? or is there a package i could  
> use? i did some quick search in the help files and R sites but could  
> not find any answers.

The chron package has a wide assortment of functions of that sort.

Looks like Mondays would be 1

 > day.of.week(1,15,2009) # a Thursday
[1] 4
 > day.of.week(1,18,2009) #Saturday
[1] 0
 > day.of.week(1,17,2009) #Sunday
[1] 6


-- 
David Winsemius




More information about the R-help mailing list