[R] extract week from date

Pingping Zheng pingping.zheng at lancaster.ac.uk
Thu Apr 11 17:18:20 CEST 2002


Juan Ramon Gonzalez wrote:

>Hello R-users,
>
>Does anyone know how obtain the week of a date?  
>(in SPPS the instruction is "xdate.week")
>
>Thanks,
>
>Juan Ramon
>
>-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
>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
>_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
weekday<-format(x, "%w")
will change the date x into week as decimal number (0-6, Sunday is 0), or
week<-format(x, "%U%)
week of the year as decimal number (00-53) using the first Sunday as day 
1 of week 1, or
week<-format(x, "%W")
week of the year as decimal number (00-53) using the first Monday as day 
1 of week 1.

See help.start("strptime").

Pingping Zheng

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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