[R] chron is.weekend() function

Paul Hewson PHewson at devon.gov.uk
Fri Sep 7 10:38:07 CEST 2001


Hello,

I have a dataset which has fields giving both calendar date and weekday.   I
know better functions are now available, but I am still using chron because
of the is.holiday() function and a homemade (even Heath Robinson would be
ashamed) is.daylight() function. 

As a check for typos in the data input, I checked that the dates matched the
weekdays.   I'm getting some confusing results from the is.weekend function
in chron.   For example (in US format: mm/dd/yy):

> mb.df$dtg[is.weekend(mb.df$dtg) == FALSE & mb.df$Weekday == "Sun"]
  [1] (09/24/00 11:52:00) (07/30/00 13:30:00) (04/30/00 15:30:00)
  [4] (04/30/00 16:28:00) (06/04/00 17:35:00) (09/03/00 14:45:00)
  [7] (05/07/00 16:42:00) (12/17/00 11:55:00) (08/20/00 10:20:00)
 [10] (01/07/01 20:32:00) (06/18/00 15:45:00) (09/24/00 11:16:00)
 [13] (09/10/00 20:35:00) (03/18/00 17:50:00) (09/03/00 09:20:00)
 [16] (06/18/00 14:37:00) (09/24/00 15:47:00) (09/03/00 20:38:00)

I have checked most of these dates on my calendar and it agrees with the
original dataset that they are in fact Sundays.   Also, I note that
is.weekend() seems to think that Fridays from 2000 onwards are weekends.

The dataset contains data from 1996 until early 2001 and chron's
is.weekend() resolved dates correctly prior to 2000.   From the command line
however more recent dates are also resolved correctly.   For example I
tried:

> is.weekend("09/02/01")
 [1] TRUE

and

> is.weekend("09/03/01")
 [1] FALSE

which is correct and therefore gives me some worries about my data, but I
would really appreciate any ideas as to where I should start looking.

Thanks

Paul

This was run on R 1.3.0 on Mandrake 7.1 with chron 2.2-17   

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Paul Hewson     tel. (01392) 382773
Data Analyst and Research Officer

Road Safety Team, Environment Directorate, 
Devon County Council,
1st Floor, Lucombe House,
County Hall
Topsham Road
Exeter EX2 4QW

tel (01392) 382773   fax (01392) 382135
email phewson at devon.gov.uk
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list