Here are three different ways (using x as defined in your 
post):

 with( month.day.year(x), day.of.week(month,day,year) )

 do.call( "day.of.week", month.day.year(x) )

 as.numeric(x-3)%%7   # uses fact that chron(3) is Sunday

---
Date:   Mon, 1 Mar 2004 22:18:33 +0530 
From:   Ajay Shah <[EMAIL PROTECTED]>
To:   r-help <[EMAIL PROTECTED]> 
Subject:   [R] Find out the day of week for a chron object? 

 
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?

Thanks,

-ans.

-- 
Ajay Shah Consultant
[EMAIL PROTECTED] Department of Economic Affairs
http://www.mayin.org/ajayshah Ministry of Finance, New Delhi

______________________________________________
[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

Reply via email to