[R] Converting daily data series to monthly series
Rubén Roa
rroa at azti.es
Wed Apr 21 07:55:33 CEST 2010
> -----Mensaje original-----
> De: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] En nombre de zowiti at ncst.go.ke
> Enviado el: miércoles, 21 de abril de 2010 5:16
> Para: r-help at r-project.org
> Asunto: [R] Converting daily data series to monthly series
>
> Hi Users,
> I have daily series of data from 1962 - 2000, with the data
> for February 29th in leap years excluded, leaving 365 daily
> values for each year. I wish to convert the daily series to
> monthly series. How can I do this using the zoo package or
> any other package?
>
> Thanks
>
> ZABLONE OWITI
> GRADUATE STUDENT
> Nanjing University of Information, Science and Technology
> College of International Education
Let df be your dataframe,
#In case you have to format your data as date before setting the montth
df$date <- as.Date(df$date, "%d/%m/%Y")
#Getting year, month and week from your correctly formatted date
df$Year <- as.numeric(format(df$date, "%Y")) #Year
df$Month <- as.numeric(format(df$date, "%m")) #Month
df$Week <- as.numeric(format(df$date, "%W")) +1 #Week
____________________________________________________________________________________
Dr. Rubén Roa-Ureta
AZTI - Tecnalia / Marine Research Unit
Txatxarramendi Ugartea z/g
48395 Sukarrieta (Bizkaia)
SPAIN
More information about the R-help
mailing list