[R-sig-Geo] How to get the number of week with "zoo"

Jan Verbesselt janverbesselt at gmail.com
Fri Dec 2 13:58:26 CET 2011


This is not a r-sig-geo question but r-help. Also, please create a reproducible example.
For now try;
?as.integer
dt <- as.Date("2007-03-01") # or
dt <- strptime("2007-03-01","%Y-%m-%d")
as.integer(format(dt,"%m"))
as.integer(format(dt,"%U"))
# etc.
%U
Week of the year as decimal number (00–53) using Sunday as the first day 1 of the week (and typically with the first Sunday of the year as day 1 of week 1). The US convention.



On 02/12/2011, at 12:23 PM, CRISTINA ARJONA wrote:

> Dear list,
> 
> I have an object of class zoo and use time() to extract the times:
>> class(Equiwz2010)
> [1] "zoo"
>> a = time(Equiwz2010)
> 
> 
> How could I convert the elements of a to the week of the year
> as integers (between 1 and 52)?
> 
> I've tried extracting the month and the day,
>> as.vector(days(a[30]))
> [1] "12"
>> as.vector(months(a[30]))
> [1] "diciembre"
> 
> but cannot find the way of getting the month as an integer
> (i.e., 12 for the example above).
> 
> Thanks!
> 
> *CRISTINA*
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list