Re: [R] Days of the week?

From: Dirk Eddelbuettel <>
Date: Thu 25 Jan 2007 - 02:07:18 GMT

On 24 January 2007 at 17:39, John McHenry wrote:

| What is the "standard" way to get the day of the week from a date such 
| as as.Date("2006-12-01")? It looks like fCalendar has some functions
| but this requires a change in the R locale to GMT. Is there another way?

Yes, go to POSIXlt and extract the wday field (see ?POSIXlt for more):

> as.POSIXlt(as.Date("2006-12-01"))$wday
[1] 5
> as.POSIXlt(as.Date("2006-12-01")+0:6)$wday
[1] 5 6 0 1 2 3 4


Hell, there are no rules here - we're trying to accomplish something. 
                                                  -- Thomas A. Edison

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Thu Jan 25 13:53:57 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 25 Jan 2007 - 03:30:31 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.