On Mon, Mar 01, 2004 at 10:18:33PM +0530, Ajay Shah wrote: > I know that this is correct: > > library(chron) > x = dates("01-03-04", format="d-m-y", out.format="day mon year") > print(x) > > It gives me the string "01 Mar 2004" which is correct. > > > I also know that I can say: > > print(day.of.week(3,1,2004)) > > in which case he says 1, for today is monday. > > > My question is: How do I combine these two!? :-) I have a data file > which is being parsed nicely and read in using the chron() function. I > need to identify fridays and treat them differently. So I need to run > the day.of.week function. But day.of.week() doesn't eat a chron > object, he insists he wants m,d,y. This seems quite odd. Any idea what > I can do?
Chron and date are older packages, you may want to use the more recent (and very powerful) DateTimeClasses > parsedDate <- strptime("01-03-04", "%d-%d-%y") > format(parsedDate) [1] "2004-01-03" > class(parsedDate) [1] "POSIXt" "POSIXlt" > weekdays(parsedDate) [1] "Saturday" Start with help(DateTimeClasses), if you ever used the C functions strptime and strftime it shouldn't be too foreign. And do look at the mailing list archives (and/or Google), as questions get answered on this quite often. Dirk -- The relationship between the computed price and reality is as yet unknown. -- From the pac(8) manual page ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html