On Mon, 12 Dec 2005, ronggui wrote:
x<-as.Date(c("2005-07-01", "2005-07-02","2005-07-03","2005-07-04","2005-07-05"))
weekdays(x)
[1] "ÂÃÂÇÂÆÂÚÂÃŽÂÃ¥" "ÂÃÂÇÂÆÂÚÂÃÂù" "ÂÃÂÇÂÆÂÚÂÈÂÕ" "ÂÃÂÇÂÆÂÚÂÒ»" "ÂÃÂÇÂÆÂÚ¶Âþ"
[1] "ÂÆÂßÂÔÂÂ" "ÂÆÂßÂÔÂÂ" "ÂÆÂßÂÔÂÂ" "ÂÆÂßÂÔÂÂ" "ÂÆÂßÂÔÂÂ"
He asked for week numbers. That's nothing like as easy, as it is not
well-defined. But
strftime(as.POSIXlt(x), "%U")
[1] "26" "26" "27" "27" "27"
is one possibility ("%W" is another). This approach will do the other
requests just as easily.
======= 2005-12-12 20:17:38 ÂÄÂúÂÔÂÚÂÀ´ÂÃÂÃ…ÂÖÂÃÂôµÂÀ£º=======
Thanks!
That solves my problem for year numbers and month numbers
Any idea how to do this for week numbers?
Regards,
Richard
On 12/12/05, ronggui <042045003 at fudan.edu.cn> wrote:
This is one way to do it.
x<-c("2005-07-01", "2005-07-02","2005-07-03","2005-07-04","2005-07-05")
x
[1] "2005-07-01" "2005-07-02" "2005-07-03" "2005-07-04" "2005-07-05"
[1] "2005" "2005" "2005" "2005" "2005"
[1] "07" "07" "07" "07" "07"
[1] "01" "02" "03" "04" "05"
======= 2005-12-12 20:06:00 ÂÄÂúÂÔÂÚÂÀ´ÂÃÂÃ…ÂÖÂÃÂôµÂÀ£º=======
Hi,
Given a frame with calendar date's:
"2005-07-01", "2005-07-02","2005-07-03","2005-07-04","2005-07-05",etc.
I want to extract the following from these dates:
week number
month number
year number
Any ideas how to accomplish this?
Many thanks.
Regards,
Richard